Mapping Vietnam
This is about building a web mapserver to share maps of Vietnam
Obtain source maps
If you already know the numbers of the maps you need,
- Go to USGS site http://store.usgs.gov/
- Click Advanced Search
- Enter map number in Old Material
- Click "Search"
- Click on the map image
- Save the PDF file
Samples for testing
- 1501ANC4810
- 1501ANC4811
- 1501ANC4815
You can also use the search features to find what you need.
Working with GeoPDFs
The GeoPDFs downloaded from USGS were scanned from paper maps, converted to a digital form (probably TIFF) and then georeferenced. Then they were converted to GeoPDF format using TerraGo Publisher.
Each scan covers only a relatively small area on the ground. So to create a complete seamless map for use on the web, we must
- Convert GeoPDFs to some format that we can further process.
- Remove the collars (the border containing legend, dates, etc).
- Process the set of resultant files into tiles that can be served.
Step one: Reading GeoPDF
If you are using ArcMap you can use "TerraGo Publisher for ArcGIS" ($2700) to import GeoPDFs directly. At this point, you can treat the GeoPDF data as you would any other ArcMap data source. Unfortunately $2700 is outside my budget.
Another excellent commercial product is Global Mapper (retails for $349). It can read the PDFs and export them as GeoTIFFs. An added plus, it has code to remove the collars and can also reproject the files if needed. I am told it is scriptable too.
You could ignore the geospatial encoding in the source PDFs and convert them into a format (TIFF for example) readable by ArcMap and then georeference it, but that's a lot of work given the PDF is already georeferenced!
The very latest version of GDAL (1.8.0) can read GeoPDFs. It's free and I have worked with it in the past, so I am giving it a try.
Recipe to convert a GeoPDF to a GeoTIFF using GDAL
% gdal_translate -of GTiff -co "TILED=YES" -co="TFW=YES" 1501ANC4815_geo.pdf 1501ANC4815_geo.tif
This generated a 47 MB TIFF that is 4470 x 3375 pixels.
You can learn more about GeoTIFF options here: http://www.gdal.org/frmt_gtiff.html A good one to use might be "-co "COMPRESS=LZW"
Step two: Removing collar
With Global Mapper this is as simple as checking an option box for the layer.
Working with my sample Vietnam maps, what I want to do is develop an algorithm to detect the border of the actual map, then trim away the outside.
Trimming away is easy, here is an expanded GDAL recipe.
Using pixels (trial and error): -srcwin xoff yoff xsize ysize
% gdal_translate -srcwin 350 0 4120 2750 -of GTiff -co "TILED=YES" 1501ANC4815_geo.pdf 1501ANC4815_geo.tif
Using map coords (using data from map): -projwin ulx uly lrx lry
% gdal_translate -projwin 104.5 9 106 8 -of GTiff -co "TILED=YES" 1501ANC4815_geo.pdf 1501ANC4815_geo.tif
Then again... look at the gdalinfo above. I should be able to extract the numbers to use from the metadata.
Notes
GeoPDF is a trademark of TerraGo. The generic term is "geospatial pdf". Please in your mind translate all references to GeoPDF in this document to "geospatial pdf". Thank you.