Suppose I have a set of coordinates in latitude and longitude.
What would be the easiest way to export those to an SVG file?
I'd rather do this programatically (any language or library will do) rather than manually, but can revert to that if necessary.
Answer
If you have your spatial data in a PostGIS database, try ST_AsSVG
, e.g.:
postgis=# SELECT ST_AsSVG(ST_MakePoint(1797227.3141, 5431330.2559));
st_assvg
--------------------------------------------------
cx="1797227.3141000001" cy="-5431330.2559000002"
(1 row)
(The linestring and polygon conversions are much more tricky, and thus very useful to have.)
If you don't use a database and are familiar with C, you can use the liblwgeom library (from PostGIS, but independent of PostgreSQL). See the API docs for lwgeom_to_svg
.
Note: these methods only provide parts of the SVG geometric elements, not the file.
No comments:
Post a Comment