Skip to main content

Draw geodata in SVG

Project description

SVGIS

Build Status Coverage Status

Create SVG drawings from vector geodata files (SHP, geoJSON, etc).

SVGIS is great for: creating small multiples, combining lots of datasets in a sensible projection, and drawing styled based on classes in the source data. It's perfect for creating base maps for editing in a drawing program, and its CSS-based styling gives great flexibility for styling.

svgis draw input.shp -o out.svg
svgis draw south_dakota.shp north_dakota.geojson -o dakota.svg
svgis draw england.shp scotland.shp wales.shp --style gb.css -o great_britain.svg

Documentation: http://pythonhosted.org/svgis

Install

Requires fiona, which in turn requires GDAL.

To instal GDAL:

On OS X: brew install gdal (requires Homebrew)

On Linux: sudo apt-get install libgdal1-dev

On Windows: see OSGeo4W

Then:

pip install svgis

An option feature of svgis is clipping polygons to a bounding box. This will speed things up if you need to draw only part of a very complex feature.

To support clipping output shapes, you'll need the GEOS library:

  • OS X: brew install geos
  • Linux: sudo apt-get install geos
  • Windows: GEOS is part of OSGeo4W, so you have it!

Then, install svgis with a slightly different command:

pip install svgis[clip]

Commands

The svgis command line tool includes several utilities. The most important is svgis draw, which draws SVG maps based on input geodata layers.

Additional commands:

  • svgis bounds: get the bounding box for a layer in a given projection
  • svgis graticule: create a graticule (grid) within a given bounds
  • svgis project: determine what projection svgis draw will (optionally) generate for given bounding box
  • svgis scale: change the scale of an existing SVG
  • svgis style: add css styles to an existing SVG

Read the docs for complete information on these commands and their options.

Examples

Draw the outline of the contiguous United States, projected in Albers:

curl -O http://www2.census.gov/geo/tiger/GENZ2014/shp/cb_2014_us_nation_20m.zip
unzip cb_2014_us_nation_20m.zip
svgis draw cb_2014_us_nation_20m.shp --crs EPSG:5070 --scale 1000 --bounds -124 20.5 -64 49 -o us.svg

The next two examples use the Natural Earth admin-0 data set.

Draw upper income countries in green, low-income countries in blue:

/* style.css */
.income_grp_5_Low_income {
    fill: blue;
}
.income_grp_3_Upper_middle_income {
    fill: green
}
.ne_110m_lakes {
    fill: #09d;
    stroke: none;
}
svgis draw --style style.css --class-fields income_grp ne_110m_admin_0_countries.shp ne_110m_lakes.shp -o out.svg

Draw national boundaries and lakes in Europe using an Albers projection, simplifying the output polygons, and draw Germany in purple.

svgis draw ne_110m_admin_0_countries.shp ne_110m_lakes.shp \
    --crs EPSG:102013 \ 
    --scale 1000 \ 
    --simplify 90 \ 
    --style '.ne_110m_admin_0_countries { fill: tan } .Germany { fill: purple }' \
    --style '.ne_110m_lakes { fill: #09d; stroke: none; }' \ 
    --class-fields name \ 
    --bounds -10 30 40 65 \ 
    -o out.svg

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

svgis-0.4.6.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

svgis-0.4.6-py2.py3-none-any.whl (28.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file svgis-0.4.6.tar.gz.

File metadata

  • Download URL: svgis-0.4.6.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.2

File hashes

Hashes for svgis-0.4.6.tar.gz
Algorithm Hash digest
SHA256 b89bfaab00095e9c47214ed8e536302ddd1ae7c31f0e289e1cbe9fd7ab513dc9
MD5 81a21efbc15d54abdc3716432f5b0b35
BLAKE2b-256 8a727e2f6e38e58c44ce12d072320835aa7359392b2a936a82dfcf67fbd346d7

See more details on using hashes here.

File details

Details for the file svgis-0.4.6-py2.py3-none-any.whl.

File metadata

  • Download URL: svgis-0.4.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.2

File hashes

Hashes for svgis-0.4.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4d0ccd5ade292f58f82f8da42e6f091cfc47dfb849ce351cb0de659647263a59
MD5 8bd4b8bf68a41ec685bff5ca8ec55168
BLAKE2b-256 ce644322eeff2f85aca28dabb09f561f29860828da2e6493e3941141eb20dfc0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page