Skip to main content

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

Project description

SVGIS

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

Complete documentation, with more examples and explanation of classes and methods: https://svgis.readthedocs.io/en/stable/

Install

Requires fiona, which in turn requires GDAL.

See the GDAL docs for install info.

Then:

pip install svgis

An optional 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.

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 the LAEA Europe projection, simplifying the output polygons, and coloring Germany in purple.

svgis draw ne_110m_admin_0_countries.shp ne_110m_lakes.shp \
    --crs EPSG:3035 \ 
    --scale 1000 \ 
    --simplify 90 \ 
    --style '.ne_110m_admin_0_countries { fill: tan } #Germany { fill: purple }' \
    --style '.ne_110m_lakes { fill: #09d; stroke: none; }' \ 
    --id-field 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.5.2.tar.gz (863.9 kB view details)

Uploaded Source

Built Distribution

svgis-0.5.2-py2.py3-none-any.whl (40.9 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: svgis-0.5.2.tar.gz
  • Upload date:
  • Size: 863.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.26.0

File hashes

Hashes for svgis-0.5.2.tar.gz
Algorithm Hash digest
SHA256 9121e6c60cac6a6eb65b49a09898f67e90edda2f2c85819e8168a5a14ed2ddad
MD5 fec48f7a85b619322b80c5ecd574af07
BLAKE2b-256 57c6f9a7184502f9731ec4750fb753cc7d6dbbd5d9e3382ee7a866c4ff075cc5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: svgis-0.5.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 40.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.26.0

File hashes

Hashes for svgis-0.5.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7c7fcc980501cedab21f433088871cbcd7130815cb2c1fbd9cdbaf6eb9ebbd92
MD5 bf48682fbfd7a2ef0fe020adf1d50328
BLAKE2b-256 38026a008f9effe98898a4846f2f396147e906267bd7472ce34477c2ace30bd0

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