dimanche 17 février 2019

Project: Nat Geo ADK Trails Illustrated to MBTILE & KMZ

I have my own copy of National Geographic's 2007 "Adirondack Park" Trails Illustrated, and I've always been frustrated by how clunky the program is, and how useless it is when you're not sitting in front of your desktop. Better mechanisms now exist to package up the data from the now defunct software, which can no longer be purchased or viewed electronically.

So, I took it upon myself to export it to MBTILE and KMZ for use on mobile phones (e.g. LocusMaps on Android & MapPlus on Apple) and GIS programs (e.g. Google Earth, QGIS, and GlobalMapper).

Major credit goes to Tom Trebisky for reverse engineering the proprietary binary format NatGeo uses on disc (.TPQ files). You can find his software (written in C) on his website here. His software is an open source viewer (similar to the proprietary program) that can also run on Linux & Mac desktops, in addition to Windows. His software also allowed single exports of images at a time.

First I wrote some software in Python to parse the approximately 225 TPQ files from the disk, and export all the JPEGs. Each TPQ file contains 16 images that make up a 4x4 grid.

With the JPEGs extracted, I then used Image Magick to stitch the images together across rows, and then across columns. Putting all 16 images together results in a maplet that's 1144 pixels wide, and 1572 pixels high, that covers a 0.125 x 0.125 lat/long area. Then, for each latitude of data, I stitched the maplets together left to right. At the widest point, the rows were as many as 17 maplets across, or nearly 20,000 pixels. The result was 15 images that when laid out north to south completed the entire map.

I then wrote a KML file to setup the 15 image overlays in Google Earth using their appropriate locations. At this point, I realized that Google Earth has a texture map limit based on your video card performance, so I couldn't view the widest images. In Google Earth, you can view this limit by going to Help => About Google Earth => Maximum Texture Size. I had to use Image Magick to split the widest images in half, and edited the KML file accordingly to remap them. From Google Earth, I then saved the KMZ file, packaging all the images into one 98MB file.

Then using Global Mapper, I loaded the resultant KMZ file and exported the Raster imagery to a 460MB MBTILE file. The zoom levels range from 10 (entire ADK park) down to 15 (zoomed in all the way).

All told, I spent about 8 hours on this project spread out over the past several weeks. I learned a lot with this project, including that I never want to do it again :-) Fortunately, most Nat GEO Topo disks utilize USGS topo imagery, which is now available by simpler means.


Aucun commentaire:

Enregistrer un commentaire