With a fragment of SVG like this:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'> <svg shape-rendering="geometricPrecision" height="180" width="360" viewBox="-180 -90 360 180" xmlns="http://www.w3.org/2000/svg"> <style type="text/css"> path { stroke: #000000; stroke-width: 0.02px; stroke-linecap: round; stroke-linejoin: round; fill: red; } </style> <path d='
followed by a PostGIS ST_AsSVG query, such as SELECT ST_AsSVG(geom, 0, 4) FROM gadm1 WHERE gid_1 = 'USA.5_1';, and then the end of the path and the SVG document:
'/> </svg>
We can assemble an SVG file showing a polygon from a GIS database.
Example (California). The large SVG file may not render correctly in web browsers – one option is to add an ST_Simplify in the query if this is required.
Coordinates in SVG are relative to the box defined by viewBox, so adjust the height="180" width="360" to change the size (scale) of the map, and the viewBox to (for example) crop the drawing. Add additional <path> elements to include multiple shapes.