GDAL – Convert GeoPDF Files Using GDAL Command Line Tools

command lineconvertgdalgeopdfpython

I'm attempting to convert a USGS US Topo GeoPDF in Windows. I'm using GDAL 1.11.1. My initial attempts were with this Python script, which automates the process by feeding a command to the Windows Command Prompt. After some initial problems (I couldn't get past line 10), I decided to try directly with the Command Prompt. I used this USGS resource as a guide, which offers step-by-step instructions for using GDAL in the Command Prompt. To simplify the process, I have been following the guide literally and using the same Santa Fe topo map. When I enter the following command:

gdalinfo NM_Santa_Fe_20131108_TM_geo.pdf –mdd LAYERS

I get this error:

gdalinfo failed - unable to open 'NM_Santa_Fe_20131108_TM_geo.pdf'

I found a few different resources that said that this error could originate from the GeoPDF file format not being compiled into the build, and suggested the following command:

gdalinfo --formats

When I run this, the GeoPDF format is indeed listed:

PDF (rw): Geospatial PDF

GDAL functions properly if I read in other formats (PNG, TIF). Does anyone have experience with this issue?

Best Answer

After finding the geopdf files, I get the same error message with GDAL 1.11.0 that was shipped with QGIS Chugiak, although gdalinfo --formats lists the pdf driver as rw.

But it works with GDAL 1.11.1 shipped with QGIS Brighton, current OSGeo4W and the binaries from gisinternals.

See also How to add Georeferenced PDF as layer to QGIS 2.0? for some bug tickets that may have been solved lately, especially http://hub.qgis.org/issues/8912 for handling of USGS Topo pdfs.

By the way, you can now use ogr2ogr -f sqlite out.sqlite in.pdf to store the vector layers from the pdf into a sqlite database and display that in QGIS:

enter image description here

This looks far better in detail than the rasterized output of gdalwarp (and saves lot of disk space too).

Related Question