2

I need to process a batch of 3rd party PDF files to

  • extract the bounding lat/long box
  • convert them to a .mbtiles format

It looks like the gdal is the go to tool for this but non of the gdal command recognise my pdf as geo referenced. For instance:

gdalinfo 00989I11.PDF
ERROR 4: `00989I11.PDF' not recognized as a supported file format.
gdalinfo failed - unable to open '00989I11.PDF'.

I installed gdal 2.4.1 on macOS using brew install gdal When I open the same PDF in Acrobat Reader, I can see the lat/long when moving my cursor:

You can download the sample PDF file here enter image description here

3
  • no it doesn't. Anything that can be from command line or via an API though as I will need to process hundreds of pdfs
    – Jan
    Apr 23 '20 at 5:50
  • Do you know what coordinate system it is?
    – BERA
    Apr 23 '20 at 5:56
  • it should be EPSG:4326
    – Jan
    Apr 23 '20 at 6:22
3

On my Ubuntu box gdal 2.2.3 can read your PDF. Please check the supported formats:

gdalinfo --formats

There should be a line (among several ones):

PDF -raster,vector- (rw+vs): Geospatial PDF

If no PDF support compiled into your gdal, you should look for another binary release or compile it from sources.

The projection is "Lambert conformal conic 2sp". I cannot find this projection in the EPSG file of proj. Here is the gdalinfo of your PDF:

Files: 00989I11.PDF
Size is 807, 1237
Coordinate System is:
PROJCS[,
    GEOGCS["GCS_North_American_1983",
        DATUM["North_American_Datum_1983",
            SPHEROID["GRS_1980",6378137.000,298.25722210]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Lambert_Conformal_Conic_2SP"],
    PARAMETER["False_Easting",0.000],
    PARAMETER["False_Northing",0.000],
    PARAMETER["Central_Meridian",-120.64261111111102],
    PARAMETER["Latitude_Of_Origin",35.23727777777781],
    PARAMETER["Standard_Parallel_1",45.00000000000001],
    PARAMETER["Standard_Parallel_2",33.00000000000001],
    UNIT["Inch",0.02540005080010]]
Origin = (-1807206.783370411256328,2042995.121725840726867)
Pixel Size = (3333.435032599861188,-3334.740105071813559)
Metadata:
  AUTHOR=
  CREATION_DATE=D:20190718071421-04'00'
  CREATOR=MicroStation 8.11.9.867 by Bentley Systems, Incorporated
  NEATLINE=POLYGON ((-1487397.02629635 -1654170.76281271,563065.530890709 -16541
70.76282236,563065.530903317 1615087.4963082,-1487397.02636315 1615087.49628256,
-1487397.02629635 -1654170.76281271))
  PRODUCER=Adobe PDF Library 9.0
  TITLE=00989I11
Corner Coordinates:
Upper Left  (-1807206.783, 2042995.122) (121d 9' 6.33"W, 35d42'19.71"N)
Lower Left  (-1807206.783,-2082078.388) (121d 8'43.18"W, 34d45'28.84"N)
Upper Right (  882875.288, 2042995.122) (120d23'37.95"W, 35d42'22.90"N)
Lower Right (  882875.288,-2082078.388) (120d23'49.26"W, 34d45'31.98"N)
Center      ( -462165.748,  -19541.633) (120d46'19.17"W, 35d13'57.77"N)
Band 1 Block=807x1 Type=Byte, ColorInterp=Red
Band 2 Block=807x1 Type=Byte, ColorInterp=Green
Band 3 Block=807x1 Type=Byte, ColorInterp=Blue

QGIS can read and display it at the right position (but projection is marked as unknown), QGIS is based on gdal, so probably on your machine it won't work.

enter image description here

1
  • yeah that's exactly what I was trying. It looks like on macOS I need brew install gdal2-pdf from github.com/OSGeo/homebrew-osgeo4mac. I'm compiling it now and will report back if that works. If that does not work, I'll install Ubuntu in a VM.
    – Jan
    Apr 23 '20 at 6:52
2

I'm answering my own question: I needed a version of gdal which supports pdf. On macOS it's osgeo4mac

brew tap osgeo/osgeo4mac
brew install gdal2-pdf
export GDAL_DRIVER_PATH=/usr/local/lib/gdalplugins

Then gdalinfo supports pdf:

gdalinfo --formats | grep PDF
  PDF -raster,vector- (rw+vs): Geospatial PDF

And the file from my original question can be inspected or converted to other formats:

gdalinfo 00989I11.PDF | grep -A 4 "Corner Coordinates:"
Corner Coordinates:
Upper Left  (-1807172.000, 2042985.000) (121d 9' 6.29"W, 35d42'19.70"N)
Lower Left  (-1807172.000,-2082410.000) (121d 8'43.15"W, 34d45'28.56"N)
Upper Right (  880032.000, 2042985.000) (120d23'40.84"W, 35d42'22.90"N)
Lower Right (  880032.000,-2082410.000) (120d23'52.11"W, 34d45'31.72"N)

Convert to tiff:

gdal_translate 00989I11.PDF 00989I11.tiff
    Input file size is 806, 1237
    0...10...20...30...40...50...60...70...80...90...100 - done.

Thanks @Zoltan for pointing me to the right direction

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.