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.4.tar.gz (864.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

svgis-0.5.4-py2.py3-none-any.whl (40.5 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for svgis-0.5.4.tar.gz
Algorithm Hash digest
SHA256 2fa24bdb5a4c5f0dce6754505a9bff2aa165d67707f4a05df8b3828e5acaadf5
MD5 aaa291c59b99dd8dd1a460fca6b32943
BLAKE2b-256 123891141cdec10f8b3699623ae73241f7becc78e5377ed3979eac66b9114fec

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for svgis-0.5.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b77853b16153114ff3a27fc2103d3605d43b420fd93afc48683b4412e0cd70e7
MD5 a146901dca32b165a5494ce2c392ee98
BLAKE2b-256 b7b7793308061a514d109167a0c3c0be293f38e630faa68fc9dc0113f9135db6

See more details on using hashes here.

Supported by

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