Translating US Topo 7.5 min GeoPDF's to other custom raster formats with GDAL.
A guide to customizing and translating the US Topo GeoPDF to other raster formats. Create georeferenced rasters which better fit your project needs from the layers of the US Topo GeoPDF.
- GDAL >= 1.8.0 or to create GeoPDF GDAL >= 1.10.0
- PDF GDAL Driver
Check to verify GeoPDF format is avaiblale with your GDAL installation.
$ gdalinfo --formats
[...]
PDF -raster,vector- (rw+vs): Geospatial PDF
[...]
*Note: Example commands should apply to any platform with GDAL
Download the example Raleigh West NC US Topo
Retrieve the metadata information for the Raleigh West US Topo and the avaiblale data layers which will be used to customize output rasters.
$ gdalinfo -mdd LAYERS raleigh_west.pdf
We will create a GeoTiff of only the terrain data (hillshade and contours) by explicitly including the layers to be used in the command. This output will also include the US Topo map collar, legend, and grids.
$ gdal_translate -of "GTiff" -co COMPRESS=DEFLATE -co TILED=YES \
--config GDAL_PDF_LAYERS "Map_Collar,Map_Frame.Projections_and_Grids,Map_Frame.Terrain" \
--config GDAL_PDF_BANDS 3 --config GDAL_PDF_DPI 300 \
raleigh_west.pdf raleigh_west_terrain.tif
We will create a GeoTiff of only the vecotr data by explicitly excluding the raster layers (Orthoimagery and Shaded Relief). This output will also include the US Topo map collar, legend, and grids.
$ gdal_translate -of "GTiff" -co COMPRESS=DEFLATE -co TILED=YES \
--config GDAL_PDF_LAYERS_OFF "Map_Frame.Terrain.Shaded_Relief,Images" \
--config GDAL_PDF_BANDS 3 --config GDAL_PDF_DPI 300 \
raleigh_west.pdf raleigh_west_vector.tif
We will create a GeoTiff clipped to the topo neatline of only the vector data. This output could be used to mosaic/stitch adjacent clipped topos to create a larger, seamless map.
*Note - This example uses a Node.js package Wellknown to convert the topo's neatline Well Known Text geometry to GeoJSON for clipping. If Node.js is not available on your system, the projected neatline geojson is included in this project.
# Save the neatline geometry from the GeoPDF topo as a variable
$ NEATLINE=$(gdalinfo raleigh_west.pdf | grep NEATLINE | sed 's/^.*POLYGON/POLYGON/')
# Install wellknown to convert the neatline WKT to unprojected geojson
$ npm install -g wellknown
$ echo $NEATLINE | wellknown > neatline_unprojected.geojson
# Project the geojson to the topo UTM Zone 17N NAD 83
$ ogr2ogr -f GeoJSON -a_srs EPSG:26917 neatline.geojson neatline_unprojected.geojson
# Translate and clip topo to the neatline with only vector data.
$ gdalwarp -of GTiff -dstalpha -cutline neatline.geojson \
-co COMPRESS=DEFLATE -co TILED=YES --config GDAL_PDF_LAYERS_OFF \
"Map_Collar,Images,Map_Frame.Projections_and_Grids,Map_Frame.Terrain.Shaded_Relief" \
--config GDAL_PDF_BANDS 3 --config GDAL_PDF_DPI 300 \
raleigh_west.pdf raleigh_west_vector_clip.tif
- US Topo Program information
- Map based browsing and downloads Map Store
- Text and attribute based search ScienceBase
- Browse direct downloads
- CLI Commands' Reference GDAL Utilities
- GeoPDF format information
- GeoTiff format information
- Command cheat sheet
Andrew Burnes apburnes@gmail.com