0

I am attempting to use ogr2ogr to convert a PDF to a SHP through the OSGeo4W shell, part of the QGIS installation (3.6 i think) on windows 10. I have used this before successfully but been a while so unsure why it isn't working. I have tried using 2 PDFs (both georeferenced - i can see the latlong). Both PDFs are recognized in GDALInfo and all the info is provided easily.

When run in ogr2ogr i use the simple following line:

ogr2ogr dest.shp source.pdf

but get this error

Unable to open datasource `source.pdf' with the following drivers.
  -> `JP2ECW'
  -> `OCI'
  -> `SOSI'
  -> `PCIDSK'
  -> `netCDF'
  -> `JP2OpenJPEG'
  -> `PDF'

It has the PDF driver (which works fine in GDALInfo) so why not here?

Thanks

Joe

To add to this:

I have just researched this a bit further and found that both PDFs were made in ArcMap. When exporting PDFs I know the georeference option needs to be checked for this to work. I also found that only the middle option "Export PDF Layers Only" works in ogr2ogr. If either the flattened version "None" and the "Export PDF Layers and Feature Attributes" are chosen then the ogr2ogr conversion does not work. I cant see a way around this

Examples PDFs here if you want to see. Only GeoPDF2.pdf seems to work in OGR2OGR. https://we.tl/t-xBBRCJg9TH

ArcMap Export Map options

8
  • gdalinfo is giving you information about a raster and ogr2ogr is trying to open a vector – Ian Turton Aug 19 '20 at 14:22
  • PDF can be either raster gdal.org/drivers/raster/pdf.html or vector gdal.org/drivers/vector/pdf.html#vector-pdf or even both at the same time. If you could convert similar PDF files before there may be some regression. – user30184 Aug 19 '20 at 14:27
  • OK thanks both - the PDF will contain some raster and vector data – Joe Nunn Aug 19 '20 at 14:34
  • although it is just the vector data that i need – Joe Nunn Aug 19 '20 at 14:34
  • then better use ogrinfo instead of gdalinfo to check the available data. – christoph Aug 19 '20 at 14:48
0

Solved this in case anyone is looking - partially anyway. By adding the command: ogr2ogr CG.shp CG.pdf --config OGR_PDF_READ_NON_STRUCTURED YES It created a georeferenced linear shapefile of all the features.

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.