- Tested with GDAL 1.11.4, released 2016/01/25
Go to https://gdal.org/download.html download and install Gdal.
gdalinfo --version
If you don't want to replace the path, you need to unzip the project into C:/geopdf/ and check that your folder tree is:
- C:/geopdf/tmp/
- C:/geopdf/data/
- C:/geopdf/scripts/ etc..
or change path in "variables.bat" script.
You have all the script example here Scripts and GeoPdf created GeoPdf and data
For use this examples you need download data and unzip it in data folder:
- C:/geopdf/data/raster/...
- C:/geopdf/data/shp/...
ogrtindex -accept_different_schemas C:/geopdf/tmp/extent.shp C:/geopdf/data/shp/osm.vrt
gdal_rasterize -burn 255 -ot Byte -tr 0.0001 0.0001 C:/geopdf/tmp/extent.shp C:/geopdf/tmp/base.tif
gdal_translate -of PDF -a_srs EPSG:4326 C:/geopdf/tmp/base.tif C:/geopdf/pdf/example1.pdf -co OGR_DATASOURCE=C:/geopdf/data/osm.vrt -co OGR_DISPLAY_FIELD="name"
ogrtindex -accept_different_schemas C:/geopdf/tmp/extent.shp C:/geopdf/data/shp/madrid_spain_osm_polygon.shp
gdal_rasterize -burn 255 -ot Byte -tr 0.0001 0.0001 C:/geopdf/tmp/extent.shp C:/geopdf/tmp/base.tif
gdal_translate -of PDF -a_srs EPSG:4326 C:/geopdf/tmp/base.tif C:/geopdf/pdf/example2.pdf -co OGR_DATASOURCE=C:/geopdf/data/shp/madrid_spain_osm_polygon.shp -co OGR_DISPLAY_FIELD="name"
gdaltindex C:/geopdf/tmp/extent.shp C:/geopdf/data/raster/madrid.tif
gdal_rasterize -burn 255 -burn 255 -burn 255 -ts 800 800 -ot BYTE C:/geopdf/tmp/extent.shp C:/geopdf/tmp/base.tif
gdal_translate -of PDF C:/geopdf/tmp/base.tif C:/geopdf/pdf/example3.pdf -co EXTRA_RASTERS=C:/geopdf/data/raster/madrid.tif -co EXTRA_RASTERS_LAYER_NAME="madrid"
gdaltindex C:/geopdf/tmp/extent.shp C:/geopdf/data/raster/madrid.tif
gdal_rasterize -burn 255 -burn 255 -burn 255 -ts 800 800 -ot BYTE C:/geopdf/tmp/extent.shp C:/geopdf/tmp/base.tif
gdal_translate -of PDF C:/geopdf/tmp/base.tif C:/geopdf/pdf/example4.pdf -co EXTRA_RASTERS=C:/geopdf/data/raster/madrid.tif,C:/geopdf/data/raster/overlay.tif -co EXTRA_RASTERS_LAYER_NAME="base","overlay"
ogrtindex -accept_different_schemas C:/geopdf/tmp/extent.shp C:/geopdf/data/shp/madrid_spain_osm_polygon.shp
gdal_rasterize -burn 255 -ot Byte -tr 0.0001 0.0001 C:/geopdf/tmp/extent.shp C:/geopdf/tmp/base.tif
gdal_translate -of PDF -a_srs EPSG:4326 C:/geopdf/tmp/base.tif C:/geopdf/pdf/example5.pdf -co EXTRA_RASTERS=C:/geopdf/data/raster/madrid.tif -co EXTRA_RASTERS_LAYER_NAME="madrid" -co OGR_DATASOURCE=C:/geopdf/data/shp/madrid_spain_osm_polygon.shp -co OGR_DISPLAY_FIELD="name"
ogrtindex -accept_different_schemas C:/geopdf/tmp/extent.shp C:/geopdf/data/shp/madrid_spain_osm_polygon.shp
gdal_rasterize -burn 255 -ot Byte -tr 0.0001 0.0001 C:/geopdf/tmp/extent.shp C:/geopdf/tmp/base.tif
gdal_translate -of PDF -a_srs EPSG:4326 C:/geopdf/tmp/base.tif C:/geopdf/pdf/extra.pdf -co EXTRA_IMAGES="C:\geopdf\images\logo.jpg,0,0,.2" -co EXTRA_LAYER_NAME="LOGO" -co OGR_DATASOURCE=C:/geopdf/data/shp/madrid_spain_osm_polygon.shp -co OGR_DISPLAY_FIELD="name" -co WRITE_INFO=YES -co AUTHOR="Fran Raga" -co PRODUCER="All4Gis" -co SUBJECT="Example" -co TITLE="Example GeoPdf" -co KEYWORDS="gdal,geopdf,all4gis"
import os
os.system(r'ogrtindex -accept_different_schemas C:\geopdf\tmp\extent.shp C:\geopdf\data\shp\osm.vrt')
os.system(r'gdal_rasterize -burn 255 -ot Byte -tr 0.0001 0.0001 C:\geopdf\tmp\extent.shp C:\geopdf\tmp\base.tif')
os.system(r'gdal_translate -of PDF -a_srs EPSG:4326 C:\geopdf\tmp\base.tif C:\geopdf\pdf\example1.pdf -co OGR_DATASOURCE=C:\geopdf\data\shp\osm.vrt -co OGR_DISPLAY_FIELD="name"')
-
Original code for inspiration: http://www.spatialthoughts.com/blog/gis/geopdf-gdal/
-
More info: https://gdal.org/drivers/vector/pdf.html#
[© All4gis 2016]