Skip to main content

Convert GeoPDF Maps to GeoTIFF with GDAL

The first thought a GIS Professional gets on seeing a GeoPDF map is how to
USGS Topo as GeoPDF
get it into GIS application. This particularly would be the case in US where USGS maps are all provided as high quality GeoPDFs and the analyst would want to derive maximum information from the maps.

A good way to get the map into a GIS application would be in the form of high resolution GeoTIFF. USGS National Map suggests using Global Mapper for the purpose [PDF]. When a similar requirement came to me I tried the operation with trial version of Global Mapper.

To my surprise I faced numerous errors and all my attempts failed. Being a long-term FOSS4G supporter I went ahead to check for FOSS4G tools which can help me out. I learnt that GDAL came with the capabilities since 1.8.0 release. I also learnt that from 1.10 release (which is currently under active development) GDAL has the capabilities to retrieve the PDF layer names which can be turned on/off. Armed with this information I went ahead to experiment and was successful.  

This post explains all that you need to know about using GDAL 1.10 to convert USGS GeoPDF maps to GeoTIFF. 

Installing GDAL 1.10 on Ubuntu

As GDAL 1.10 is currently under development we will be using SVN to pull the latest sources and install it in an exclusive location. With this installation I had three versions of GDAL on my Ubuntu 12.04 PC - 1.7* (which came with QGIS), 1.9* (came with OpenGeo suite) and 1.10 (for experimentation).

Note: If you are installing GDAL and using SVN for the first time you may have to install several pre-requisites by understanding the missing dependency errors. If you already have Ubuntu-GIS repository and working installations of GIS applications like GRASS there won't be any major issues.

Here are the commands to be used for installing GDAL 1.10.

Step 1: Create a directory where all source code will be stored. (This main directory can be used to place the sources of in-development versions of say GRASS GIS)
sudo mkdir /usr/local/src

Step 2: Create the installation directory. I chose opt as I had other GDAL versions and wanted to keep an in-development build separate.
sudo mkdir /opt/gdal_trunk

Step 3: Take over directory ownerships. Replace userid and groupid with your particulars:
sudo chown userid:groupid /usr/local/src

Step 4: Grant read-write-execute permissions for the userid and groupid to src directory:
sudo chmod ug+rwx /usr/local/src

Step 5: Use the change directory command to go into the directory:
cd /usr/local/src

Step 6: Download GDAL 1.10
svn checkout https://svn.osgeo.org/gdal/trunk/gdal gdal_trunk

Step 7: Enter gdal_trunk directory
cd /usr/local/src/gdal_trunk

Step 8: Configuration - The prefix option specifies the installation directory, --with specifies the compilation must happen with poppler [this is important for GeoPDF to GeoTIFF conversion. Without poppler support the operation fails with error code 4] and podofo support.
./configure --prefix=/opt/gdal_trunk --with-poppler --with-podofo

Step 9: Compile, install and ldconfig
make -j2 && sudo make install && sudo ldconfig

With this you will have a working installation of GDAL 1.10 inside /usr/opt/gdal_trunk. Congratulations! :)

Using GDAL 1.10 for GeoPDF to GeoTIFF conversion

Note: Correct file paths accordingly. The commands are to be typed/pasted at once.

For illustration I have used a USGS GeoPDF belonging to North Carolina state [Download (~19 MB)]. Open the PDF in Adobe Reader or use this GDAL command to get metadata and layer information in a text file.

/opt/gdal_trunk/bin/gdalinfo Downloads/NC_Windsor_North_20110909_TM_geo.pdf -mdd LAYERS >> Downloads/NC_Windsor_North.txt

I have copied the resulting file here onto Google Drive.

One can decide which layer(s) to retain and which to turn off with the above step. For instance, I decided to turn off the "Map_Collar" and "Map_Frame.Projection_and_Grids" layers. The USGS document recommending Global Mapper warns that removing map collar layer discards important metadata including coordinate annotation. Unless we remove that the map won't integrate well with other external layers which we use (as it will have all map layout elements like scale bars, creation information etc.).

The final step is to run gdal_translate for converting the GeoPDF to GeoTIFF with necessary flags.

/opt/gdal_trunk/bin/gdal_translate -of GTiff -co "TILED=YES" -co "TFW=YES" Downloads/NC_Windsor_North_20110909_TM_geo.pdf  Downloads/Windsor_North.tif --config GDAL_PDF_LAYERS_OFF "Map_Collar","Map_Frame.Projection_and_Grids" --config GDAL_PDF_DPI 300

Here is the output GeoTIFF opened in QGIS.
GeoTIFF Output
I had a vector layer for road centrelines for the same area. After doing necessary projection transformations both of them could be overlaid perfectly. [SpatialThoughts has a nice detailed post on this].
Street Centrelines overlaid on GeoTIFF image
Hope you enjoyed the post. Let me know how the conversion went via comments.


Comments

Popular posts from this blog

Resolving INS-20802: Oracle Net Configuration Assistant failed error on Windows 10

I was all excited about the migration to Windows 10 until I had to install Oracle client 12.1.0.2 on it. The Oracle client installation used to fail miserably at the last stage with this error named INS-20802.


SSL VPN: Configuring and Using Forticlient on Ubuntu, creating a Launcher

Is your primary OS at home Linux and do you use Windows only to connect to your work PC over VPN or to attend meetings? Do you often wish to connect to your work VPN from a Linux PC?  If your answer is 'Yes' to the above questions, I have an answer if your workplace uses Fortinet SSL VPN. Note that it's possible to connect to Fortinet and other VPNs like Cisco VPN from Linux through the inbuilt network manager by installing additional tools but this post would focus on using the standard Forticlient for accessing the resources on your work network.
Obtaining Forticlient The most important thing to note w.r.t. using Forticlient for Ubuntu (or any Linux distro) is to note that the client is not publicly available for download from the official website. You will have to ask your IT department to download the client for you, in case they haven't provided it.

Troubleshooting a Constantly Freezing Windows 10 PC

On my Windows 10 Home, I was being bugged by constant freezes which forced me to hard reboot now and then. Since I use Ubuntu as my primary OS, I chose to adjust with this for long. However, this became more of a trouble in the recent times with Windows starting up at 98% CPU usage and every process actually showing 0% CPU usage. That's when I decided to get into the root of the problem and resolve it. I was confident that the hardware was fine since Ubuntu worked perfectly all the time.
It turned out that many Windows 10 users, especially those who upgraded from previous versions of Windows 7 or 8 / 8.1 faced similar freezing issues. The answers at Windows Forums by Microsoft staffers generally suggested using the command sfc /scannow to verify that system files were intact. However, most users found it unhelpful and that didn't help me either.