Skip to content

Instantly share code, notes, and snippets.

@pollardld
Last active August 30, 2023 23:57
Show Gist options
  • Save pollardld/826649c275452a82fe1c45b7e734ac71 to your computer and use it in GitHub Desktop.
Save pollardld/826649c275452a82fe1c45b7e734ac71 to your computer and use it in GitHub Desktop.
GeoJSON to GeoPDF with Python Subprocess
import subprocess
# Step 2: Convert GeoJSON to GeoTIFF
# ATTRIBUTE_FIELD = ?
subprocess.run([
"gdal_rasterize",
"-a", "ATTRIBUTE_FIELD",
"-ts", "WIDTH", "HEIGHT",
"-l", "LAYER_NAME",
"i.geojson",
"o.tif"
])
# Step 2: Convert GeoTIFF to GeoPDF
subprocess.run([
"gdal_translate",
"-of", "PDF",
"o.tif",
"GeoPDF.pdf"
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment