Sunday 15 November 2015

Shapefile to SVG with ArcMap (while retaining country attributes)


Does anybody know how to export the Natural Earth 1:110m shapefile to SVG with ArcMap while retaining the country attributes?


From SVG I'm gonna try to convert it again over to RaphaelJS to achieve something like:


http://backspace.com/mapapp/javascript_world/



http://backspace.com/mapapp/javascript_world/js/world_570.js


But I'm new to all of this so I'm not sure how to go about it. Maybe there's no way but to manually add the country codes for the JS?



Answer



I created those maps, so I can describe the process I used. There's probably a better way to do it, but here's how it works for me:




  1. In ArcMap, give each state its own layer. I use layer ID's from the source layer attributes table and then a bit of ArcMap Python:


    import arcgisscripting
    gp = arcgisscripting.create()
    gp.MakeFeatureLayer_management('ne_110m_admin_0_countries','AF','"ABBREV" = \'Afg.\'')

    gp.MakeFeatureLayer_management('ne_110m_admin_0_countries','AO', '"ABBREV" = \'Ang.\'')
    gp.MakeFeatureLayer_management('ne_110m_admin_0_countries','AL', '"ABBREV" = \'Alb.\'')
    ...etc...

    This creates a new layer for each state named with that stat's two-letter ISO code.




  2. I export from ArcMap as Adobe Illustrator. In Illustrator, the layers are preserved and named as they were in ArcMap. In Illustrator I size up the shapes appropriately and do some fine-tuning on the styles. Then export as SVG.





  3. Run this perl script to convert SVG file to Raphael.js friendly json: https://gist.github.com/2655111




And that's that!


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...