0

I am using gdal_translate to convert some USFS geoPDF maps to geotiff images.
I actually set more layers off than is listed in the code snippet below but I've pulled them for clarity.
The resulting geotiff contains the desired PDF content but also has a white page border. Is it possible to for gdal_translate to do the rendering without the white border?
I've seen a site with a reference to using esri ArcGIS to remove the border after gdal_translate processing but that is very cost prohibitive.
If it is not possible to do with any of the gdal utilities, what is the best way to remove the border? Crop with photoshop and add the geospatial references back?

gdal_translate -of GTiff -co "TILED=YES" -co "TFW=YES" D:\USFSTopo.pdf D:\USFSTopo.tif --config GDAL_PDF_LAYERS_OFF Other_4,Adjacent_Quadrangles,Quad_Location_Diagram,Map.Measured_Grid --config GDAL_PDF_DPI 300
2

Run gdalinfo on the geopdf. There will probably be coordinates for a neatline as a wkt polygon in the metadata. Run gdal_translate like you have. Then run gdalwarp with -crop_to_cutline option and provide the neatline as the cutline.

Here's an example using https://www.terragotech.com/images/pdf/webmap_urbansample.pdf:

gdalinfo webmap_urbansample.pdf

gives:

...
Metadata:
  CREATION_DATE=D:20050909130953Z
  CREATOR=ESRI ArcMap 9.0.0.580
  NEATLINE=POLYGON ((724095.44784655632 7672632.7859419286,724095.44784655632 7672952.9421169758,724615.62765777006 7672952.9421169758,724615.62765777006 7672632.7859419286,724095.44784655632 7672632.7859419286))
2.7859419286,724095.44784655632 7672632.7859419286))
Subdatasets:
  SUBDATASET_1_NAME=PDF:1:webmap_urbansample.pdf
...

create a file called neatline.csv containing the neatline:

id,WKT
1,"POLYGON ((724095.44784655632 7672632.7859419286,724095.44784655632 7672952.9421169758,724615.62765777006 7672952.9421169758,724615.62765777006 7672632.7859419286,724095.44784655632 7672632.7859419286))"

Then run:

gdal_translate -of GTIFF webmap_urbansample.pdf webmap_urbansample.tif
gdalwarp webmap_urbansample.tif webmap_urbansample_c.tif -cutline neatline.csv -crop_to_cutline

Here's the initial geopdf in adobe: enter image description here Here's the final tif in qgis: enter image description here

Here's a similar question that may provide extra details: I need to extract a specific layer from a Geospatial PDF using GDAL/OGR

Here's another good example of this procedure: gdalwarp not clipping neatline properly

  • Many thanks. The process worked great except that the neatline in the PDF wasn't accurate. It gives me a good place to start. – bakerjw Feb 29 '16 at 16:13
  • I'm sorry to hear this answer didn't totally solve your problem because the neatline wasn't accurate. But I'm glad to hear it gave you a place to start. – user55937 Feb 29 '16 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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