I created a figure in Python with raster and vector data. I can save it to a PDF but I need to save it as a geospatial PDF with metadata like transform and PROJCS to open in apps like Avenza Maps. How can I do that?

I'm using rasterio, Cartopy, GeoPandas and matplotlib to create the image.


1 Answer 1


You can find GDAL Python examples from https://github.com/OSGeo/gdal/blob/master/autotest/gdrivers/pdf.py. See how SetProjection and SetGeoTransform are used.

For example around line #741

 ds = gdal.Open("tmp/pdf_update_gt.pdf", gdal.GA_Update)
    sr = osr.SpatialReference()
    ds.SetGeoTransform([2, 1, 0, 49, 0, -1])
    ds = None

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.