Skip to content

Instantly share code, notes, and snippets.

@pollardld
Last active August 31, 2023 00:10
Show Gist options
  • Save pollardld/78590f03384cbdd09aa62c94c4015faf to your computer and use it in GitHub Desktop.
Save pollardld/78590f03384cbdd09aa62c94c4015faf to your computer and use it in GitHub Desktop.
Making GeoPDFs
import subprocess
# Convert GeoJSON to GeoTIFF
# ATTRIBUTE_FIELD = ?
subprocess.run([
"gdal_rasterize",
"-a", "ATTRIBUTE_FIELD",
"-ts", "WIDTH", "HEIGHT",
"-l", "LAYER_NAME",
"i.geojson",
"o.tif"
], shell=True)
# Convert GeoTIFF to GeoPDF
subprocess.run([
"gdal_translate",
"-of", "PDF",
"o.tif",
"GeoPDF.pdf"
], shell=True)

Enter the python interpreter

python
import subprocess
# Convert GeoTIFF to GeoPDF
subprocess.run([
"gdal_translate",
"-of", "PDF",
"o.tif",
"GeoPDF.pdf"
], shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment