Create SVG from Shapefile App
Output Readme Download Replit Sel. & Copy Full


This repl creates an html files with SVG shapes for a collection of U.S. states using Python.

To view this on TripleLog, click here.


The packages should automatically install if using Replit. You need pyShp (import shapefile), shapely, pyproj, and flask. Install (with dependencies) any that need installing. You can also use fiona or other geo packages, but installing GDAL on Replit seems to not always work.

Running the file should start a flask server that will be on the localhost or your domain. Then visit {{baseurl}} (either or localhost:81) or {{baseurl}}/create to choose which states to add to your SVG. This page will then redirect you to your created html file.


Use the jinja2 templating to generate the files from templates/template.html. The syntax is similar to nunjucks.

We need to read the shapefile and grab the coordinates for whichever states we want to display.

You can use a different shapefile or geoJSON object, but you will need to adjust some of the early code to make everything work.


A template file called template.html is used to eventually create the HTML file with the final SVG shapes. The flask server then serves these files automatically once they are generated to the svgs directory.