Draw geodata in SVG
Project description
svgis
Create SVG drawings from geodata files (SHP, geoJSON, etc).
$ svgis draw in.shp -o out.svg
$ svgis draw in.shp in.geojson -o out.svg
Install
Requires fiona, which in turn requires GDAL.
Before installing, run the following on OS X: brew install gdal. On Linux: sudo apt-get -qq install -y libgdal1-dev.
Command line tools
The svgis command line tool has four commands: draw, project, scale and style. Svgis scale and svgis style will add a scaling factor or CSS style to an existing SVG file. Svgis project is a utility for printing the projection that svgis draw will generate for given bounding boxes.
The main command is svgis draw, which generates SVGs from input geodata.
svgis draw options
–bounds
Takes four arguments in min-lon, min-lat, max-lon, max-lat order.
This example draw the portion of the input file between latitudes 40 and 41 and longitudes -74 and -73 (roughly the New York City area).
svgis draw --bounds -74 40 -73 41 in.geojson out.svg
Note that coordinates are given in longitude, latitude order, since in the world of the computer, it’s better to be consistent with things like (x, y) order.
–scale
A integer scale factor. The map will be scaled by the inverse of this number.
While SVG is a vector format, clients may have trouble handling very large numbers. Use the scale option to scale down the output. Dimensions in the map will be divided by this number (so larger numbers yield smaller coordinates in the output SVG).
svgis draw --scale 1000 in.shp -o out.svg
–project
There are three ways to provide projections. Using both at the same time is unsupported. If the input file doesn’t specify an internal projection, SVGIS will assume that the coordinates are given in WGS84.
If none of these three flags are given, SVGIS will check to see if the file is already in non lat-lng projection (e.g. a state plane system or the British National Grid). If the first input file is projected, that projection will be used for the output. If the first file is in lat-long coordinates, a local projection will be generated, just like if --projection-method=local was given.
EPSG codes
Accepts a valid EPSG code.
Use this option to provide the EPSG code of a desired projection. The example will draw an svg with EPSG:2908, the New York Long Island state plane projection.
svgis draw --project EPSG:2908 in.shp -o out.svg
Proj4 strings
Accepts a string in proj4 format.
Use this option to provide a Proj4 string that defines a projection.
PROJECTION=+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
svgis draw --project $PROJECTION in.shp -o out.svg
UTM
Accepts either ‘utm’ or ‘local’.
For UTM, attempt to draw coordiantes in the local UTM projection. The centerpoint of the bounding box will be used to pick the zone. Expect poor results for input data that crosses several UTM boundaries.
svgis draw --project utm in.shp -o out.svg
Automatically generated projection
When the local argument is given, SVGIS will generate a Transverse Mercator projection that centers on the input bounding box. This generally gives good results for an region roughly the size of a large urban area.
svgis draw --project local in.shp -o out.svg
Style
–style
The style parameter takes either a CSS file or a CSS string.
svgis draw --style style.css in.shp -o out.svg
svgis draw --style "line { stroke: green; }" in.shp -o out.svg
–padding
Adds a padding around the output image.
svgis draw --padding 100 in.shp -o out.svg
–no-viewbox
By default, SVGIS uses a viewbox. If you have a problem opening the created svg file, try the ‘–no-viewbox’ option, which will create an svg where the contents are translated into the frame
svgis draw --no-viewbox in.shp -o out.svg
svgis draw -x in.shp -o out.svg
–class-fields and –id-field
Use these options to specify fields in the source geodata file to use to determine the class or id attributes of the output SVG features. In the output fields, spaces will be replaced with underscores.
For example, assume a SHP file with a countrycode, continent and currency fields:
svgis draw --class-fields continent,foobr --id-field countrycode countries.shp -o out.svg
By default, each layer is wrapped in a group (<g>) with id equal to the name of its source layer.
The result may contain something like:
<g id="countries">
<g class="North_America dollar" id="US">/* USA */</g>
<g class="Europe pound" id="UK">/* UK */</g>
<g class="Europe euro" id="DE">/* Germany */</g>
/* ... */
</g>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file svgis-0.2.0.tar.gz
.
File metadata
- Download URL: svgis-0.2.0.tar.gz
- Upload date:
- Size: 215.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aab720c2b5df000d5fcdf3540b74d3e511e9337bd9a2688986b1341ac2b5add2 |
|
MD5 | 8cf497a7b2cfc23a6978b6e929434640 |
|
BLAKE2b-256 | 887b617e2a8f9fd4bd51a70b7cb0a7052865c4ddb76c4bd44dee069b17c75a56 |
File details
Details for the file svgis-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: svgis-0.2.0-py3-none-any.whl
- Upload date:
- Size: 207.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1acf4d8281f92dc5ab4dfca9971d917a96ee7ce23751f17fd1bd94e80ea95986 |
|
MD5 | 36bc6f4e1fe3569a778a1f5152c87276 |
|
BLAKE2b-256 | 55a44d5949367b7c9188b988965a0431dc304c0f4660c32c99c9ed7042f5f727 |
File details
Details for the file svgis-0.2.0-py2-none-any.whl
.
File metadata
- Download URL: svgis-0.2.0-py2-none-any.whl
- Upload date:
- Size: 207.5 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9832048107a64ae205183de6aee6d6ccd81894e2ae86b5f275244f516db96c88 |
|
MD5 | 8aac2e207d5b2ba6b87a1a955ed165b4 |
|
BLAKE2b-256 | fe0a7002c326bd61ebc732899cac13ffafd9b52f4fb406c088147ca2e0f52462 |