ArcGIS SVG export

Because I was not entirely satisfied with the built-in SVG export option of ArcMap I wrote this short macro to do it my own way. The essential feature, compared to ArcMap’s built-in SVG export, is that I can define an (known) ID for every SVG element out of the attribute table. Thus I’m able to access my SVG elements later via JavaScript.

What the macro does:
- Exports all layers and features of your map document (mxd) to SVG
- Every layer will be preserved as SVG group
- Adds the values of the field “SVG_ID” of your attribute table to every SVG element as ID
- Units and extent are taken from the layer properties of ArcMap
- Produces clean SVG 1.1 code

What the macro does not:
- no formating – no colours, stroke-widths, etc. – everything will be visible as black in black (I just needed a clean SVG skeleton, graphic attributes I add later via interactivity)
- no HTML embedding, you get just the SVG code

If you think this can be useful for your purpose, just copy & paste the code of the text file into the Visual Basic Editor of ArcMap (Project/ArcMap Objects/ThisDocument) and hit run.

SVG-Export

  • josh

    Thanks for posting this script, for me (GIS developer in the states) it was a convenient way to uncover the mystery of SVG. Just started looking around for a free extension for ArcGIS 9 (like SVGMapper for AV 3.x) and I’m realizing I’ll probably have to write my own. Thanks.

  • Irene

    tried this script but it would not run, keeps asking me to define the SVG_ID for the shapefile.

    what could be the problem here

  • http://spanring.eu/ Christian

    You must add the field “SVG_ID” to your attribute table and put your desired IDs there.

  • Alex

    Hi Christian,

    What a simple, perfect script. Will be using it to generate “basemaps” for a basic server-side thematic map generator.

    Best regards!

    P.S. Str() and Val() in VBA are locale-invariant and eliminate a few headaches when you don’t know whether to expect 3,600.32 or 3600,32 !!

  • http://spanring.eu/ Christian

    By using the rather dumb replace(string) I’m on the safe side and got the point where it should be ;-)

blog comments powered by Disqus