Skip to content

Instantly share code, notes, and snippets.

View aido179's full-sized avatar
🚲
Working

Aidan Breen aido179

🚲
Working
View GitHub Profile
@aido179
aido179 / gist:db7a33ae3084b24c02ac23a0e2df45bb
Last active October 12, 2020 16:09 — forked from ianfieldhouse/gist:2284557
Create PNG from Shapefile - handle multiple parts
import shapefile
import pngcanvas
# Open shapefile with Python Shapefile Library
shapefile_name = 'REPLACE_WITH_SHAPEFILE_NAME' # e.g. england_oa_2001
r = shapefile.Reader(shapefile_name)
# Determine bounding box x and y distances and then calculate an xyratio
# that can be used to determine the size of the generated PNG file. A xyratio
# of greater than one means that PNG is to be a landscape type image whereas