7

I am trying to extract point data from a non-geo-referenced vector PDF file, to import into QGIS/ArcGIS. You can download a copy of the PDF file here, if interested, but I've tried to include screenshots of the relevant parts to make that unnecessary since it's such a large file (~171 MB).

The PDF file is a map of mineral resources in Afghanistan, which looks like this:

Full view of map

Here is a closeup image of a small segment of the map -- notice that it contains a bunch of labeled locations (cities/provinces, etc), colored regions (representing geological/rock types), and point data with different colored/shaped icons (representing known mineral/petroleum deposits): Closeup of map with desired point features

I am primarily interested in extracting the locations of the little icons representing the geo-locations of mineral/petroleum deposits, and using them to generate point data that I can import into QGIS. That is, for all of the icons listed in the legend below, I want to find any instances on the map and create a table that has their x,y location and "category" field that matches the categories listed in the legend: map legend

The PDF file does not appear to be geo-referenced, but the map is drawn to scale and surrounded by a lat/long-grid. The map contains the following information about the scale (and authors): scale of map

In the bottom left corner there is the following information about the projection which I feel could somehow be used to map from (x,y) coordinates in the PDF file to (x,y) coordinates in WGS84:

Projection info, orientation, data sources, etc in bottom left

Obviously, if there is an easy way for me to do this in QGIS, I'd love to know about it ... but from my searches so far, it's appears likely that I'm going to have to write code to extract the data from the PDF ...

If that is the case, then I would be interested in Python/C/C++/Scheme libraries that could be used to extract the information I described above. And if no libraries exist that can do this easily, then please share ideas about resources/techniques that might help me code my own solution for this.

Any ideas on how to tackle this problem would be useful, even if they only solve some small part of it ...


UPDATE:

So I've experimented a bit with a FOSS tool called pstoedit which can extract some of the data from the PDF file and convert it into a DXF file (a common CAD format that QGIS can work with). I used the DXF with splines format option (pstoedit -f dxfs infile.pdf outfile.dxf) to convert the file, and got a DXF file that QGIS was able to import using WSG84 (I still haven't figured out how to use the projection/reference info in the bottom left of the map to overlay this point data, in the right locations, over my base map of Afghanistan).

However, there is very little organization to this data - it's just (x,y) data and generic Text field names like "Text" or "EntityHandle" (see left sidebar in image below). And as user30184 pointed out in their answer, all of the data is jumbled together in one Layer (0). So there is no clear way for me to associate the graphical icons with the individual text labels (mineral deposit categories) from the legend. Here is what it looks like so far - I'll post more if I make more progress:

DXF file imported into QGIS

  • given that the web page says "all data presented on the map are also available in GIS format", have you tried contacting the authors or USGS? – Spacedman Nov 9 '15 at 8:11
  • I have tried contact USGS, but I don't know if they are going to get back to me ... and in the meantime I'm kind of pressed for time and was wondering if I could just extract the data easily without having to wait for their response ... and even if they do get back to me, I'd still like to know how to extract geo-data from PDFs in general, because I feel like it will be useful in cases where the authors are not reachable or willing/able to share the raw data. – J. Taylor Nov 9 '15 at 18:43
  • Its not possible to have an "in general" method, because PDF is a page description language and the page could be constructed in a zillion ways. At least they have distributed the vector version, but if the points you want don't have the right metadata you might be stuffed. Tried opening it in inkscape? Its too big for my little laptop. – Spacedman Nov 9 '15 at 19:10
  • 1
    This doesn't answer your question, but you might find it useful. We found when working in Afghanistan that a lot of maps with grid systems printed on them were deliberately wrong; so don't use the printed grid to determine coordinates. You might find useful to your research the Afghanistan geology WMS/WFS published as part of OneGeology, and Afghanistan Geological Survey – nmtoken Nov 30 '16 at 12:58
2

Since this map was likely created in Illustrator try deconstructing it with Illustrator.

Open PDF in Illustrator and all 272 appear and are correctly named.

Turn off/delete any unneeded raster such as the shaded relief

Alternatively delete ALL unneeded layers and only keep the lithology/symbols you want.

Export map to DWG of DXF

Open in ArcMap

Of course DXF/DWG is vector based so instead of points you will get the actual polygons/outlines of the symbols but you could convert to centroids with attributes with a simple script. On the other hand you will get all the vectors with "layer name" attribute. You can control editability (apeareance vs maximum editability) in the DXF/DWG export options dialog.

The benefit of this aproach is that ALL layers area preserved.

As far as georeferencing goes; convert all to shapefiles and use the spatial adjustment tools in ArcGIS. Since coordinates are given on the map, create projected points matching those coordinates and snap the corners of the grid and the tics (which also import into the same DXF as from illustrator) to these points.

Screen capture from Illustrator: enter image description here

After exort to DWG and opened in ArcMap:

enter image description here

3

You can test what GDAL can find from the PDF document with ogrinfo and gdalinfo.

ogrinfo Afghan_Mingeol_V2.pdf
Warning 4: Failed to open Afghan_Mingeol_V2.pdf, No error.
FAILURE:
Unable to open datasource `Afghan_Mingeol_V2.pdf' with the following drivers.

Result means that GDAL could not find vector data from the PDF.

gdalinfo Afghan_Mingeol_V2.pdf
Driver: PDF/Geospatial PDF
Files: Afghan_Mingeol_V2.pdf
Size is 11400, 8100
Coordinate System is `'
Metadata:
  CREATION_DATE=D:20070329115837-04'00'
  CREATOR=Adobe Illustrator CS2
  PRODUCER=Adobe PDF library 7.77
  TITLE=afghanbase1
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 8100.0)
Upper Right (11400.0,    0.0)
Lower Right (11400.0, 8100.0)
Center      ( 5700.0, 4050.0)
Band 1 Block=1024x1024 Type=Byte, ColorInterp=Red
Band 2 Block=1024x1024 Type=Byte, ColorInterp=Green
Band 3 Block=1024x1024 Type=Byte, ColorInterp=Blue

This result means that PDF file is written as a single layer. If categories were written as separate layers then you could select a certain layer with gdal_translate, write it into a new raster file and vectorize it with gdal_polygonize.py http://www.gdal.org/gdal_polygonize.html. Now I fear that you are pretty much out of luck with GDAL and QGIS.

  • Yes, it seems like I'm going to have to convert it into some kind of intermediate format, before converting to a format QGIS can handle. I tried using pstoedit to convert it to a DXF, and was at least extract point data that way but there is very little organization to it -- it basically just extracted a set of all line/path data and a set of all point data, and lumped everything together in one of those two sets. I'm going to try playing with some of pstoedit's more advanced PDF->DXF conversion options, and also look for solutions to convert it to SVG somehow ... – J. Taylor Nov 8 '15 at 23:34
3

Just change your approach. In fact, you maybe don't need to fight with technical issue.

Why?

I was able to found metadata concerning the map data you are trying to extract. Metadata reference each shapefile used to produce the map.

Then, I was able to find the original layers and not only their reference in the metadata. Look at this other USGS link and just use the shp.

PS: I may be wrong as I didn't inspect all the datasets in detail

  • Thanks for the link. It has a small subset of the data I'm looking for (petroleum wells), and the roads shapefile will be useful. However, most of the data on mineral deposits is not in any of the shapefiles you provided, and only some of the shapefiles provided cover the entire nation. I've definitely been trying to find the full dataset as well, but I've only been able to find small pieces, like the ones you linked to. – J. Taylor Nov 9 '15 at 4:24

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.