Creating Multi-Segment Raster Topo Maps with MOAGU

Author: John Hollenberg | Last updated February 8th, 2009 at 09:41pm

Introduction

MOAGU (Mother of All GPS Utilities) is a program written by Leszek Pawlowicz to create raster maps for Garmin GPS units.  The FAQ on the web site will answer most questions about the advantages and disadvantages of MOAGU maps.  He also has a web site called Free Geography Tools which has some useful and interesting articles.  There is also a review of MOAGU on gpstracklog.com.

Unlike the vector maps generally available for GPS units, the raster maps are an exact copy of a scanned map, including all symbols, text, etc. which is present on the original map.  This also means that as you zoom in the map can get blurry whereas in a vector map it will always be smooth.  To speed drawing time, Leszek has the program change the green areas on topo maps representing commercially valuable timber to white, but in all other respects they are identical.  This makes identifying your location on a paper topo map very easy.  I was interested in the program primarily to produce topo maps to be used during cross-country hikes.

This tutorial assumes that you have purchased MOAGU ($20 introductory price) and are able to create a MOAGU map following the very clear directions in the documentation.  A limitation of MOAGU is that it can only handle maps of about 100 megapixels (roughly 10,000 by 10,000 pixels).  This tutorial documents my experiences in creating a much larger map with MOAGU consisting of 27 MOAGU maps covering Joshua Tree National Park and surrounding areas (available for download here on gpsfiledepot).  The 1.3 GB size of the final map takes some time to load (30-45 seconds or so) when you turn the GPS on, and drawing a map screen when you pan takes 10-30 seconds (depending on the amount of detail on that part of the topo) on my Garmin Vista Hcx.  For hiking, the occasional redraws are not a problem.

Another limitation of the raster maps created with MOAGU is that when zooming in very rapidly my Garmin occasionally crashed (3 times during an all day hike).  This caused no harm to the Garmin or the data I was recording.  Leszek has seen this also.  Presumably it is due to a subtle bug in the Garmin firmware.  I'm not sure whether it has been reported, but I doubt Garmin would be interested in fixing a bug that would potentially decrease sales of their own maps.  The workaround is simple--don't zoom immediately after zooming.  The problem usually happened when zooming a split second after the previous zoom.  I found that holding the zoom button down until close to the 500 foot zoom level didn't create the problem, so I could easily and quickly get to the approximate zoom level I needed.

Plan Your Map Segments

I wanted to make the MOAGU segments as large as possible, to avoid having to download too many separate pieces, and because extra work is needed to make the segments fit together well.  One complication for my particular topo is that it included data from both the California and non-California databases on the USGS seamless server (odd, since the entire map is in California).  I asked the USGS about why the “seamless” database isn't seamless and got the following answer:  “There is a discrepancy between the two layers.  When in download, you will need to select both the 24k DRG Zone 11 as well as the 24k DRG (CA) Zone 11.  The reason for this, is because there is a slight color variation between the two layers.  They came from different sources and could not be seamlessly integrated.”

In addition, it turns out that the scanned topo maps at 1:24000 scale are scanned with different dots per inch for the California [24K DRG Zone 11 (CA)] and non-California [24K DRG Zone 11] sections!  When I downloaded a cross-seam region, the California DRG piece had approx 1.64 times as many pixels for the same width as the 24K DRG (not California).  This didn't create any problems in the seams, but did require some extra planning.  I decided to find the exact coordinates of the California/non-California transition, and created my segments so that they were completely in the California section, or completely in the non-California section.

A consequence of the fact that the two regions were scanned at different DPI is that MOAGU could not process as large a geographical area in the California database as the non-California database, since the limits are set by the number of pixels, not the geographic area.  I came up with the following approximate geographic size limits for the two databases:

Note that once the geoTIFF files downloaded from the USGS server are re-projected by MOAGU, they will increase somewhat in size.  For example, an 80 megapixel file was just over 100 megapixels once re-projected (the _geo.tif file created by MOAGU) from the NAD27 datum to the WGS84 datum.  While this made a couple of my pieces slightly larger than 100 megapixels, this isn't a hard and fast limit, and MOAGU processed them just fine, after giving me a warning and asking whether to proceed.

Once I knew the size limit for each piece in each section, I divided up the area I wanted to map into regular size pieces that were as large as possible, but fit within the above size constraints.  I drew a rough map on paper with the coordinates of each horizontal or vertical line.  Since the USGS seamless server allows you to enter North, South, East and West coordinates of a piece you want to download, this made it very easy to get all of the pieces without any overlap. For an upcoming map of the Southern Sierra I am working on (all in the California database) I decided to make my segments with the same coordinates as existing USGS quad maps and give each downloaded segment the same name.  This will make it easier to load one topo, and the fact that after re-projection the segments are about 70 megapixels means they are close to the optimal size.

Download The Data

I found the data download section of the USGS seamless server a bit confusing at first, so I am going to give a few suggestions about how to use it most effectively for downloading scanned 1:24000 topos.

  1. For California, look on the right side under “Display”.  Click on “Layer Extent”, then select “DRG 24K”.  This will allow you to see what areas of your topo are in California DRG vs. the non-California DRG.  See screen shot below with slanted yellow lines.  Boundary is shown with green arrow:
  2. On the right, if you click on Boundaries, then select National Atlas Federal Lands, you will also see the boundaries of the National Park:
  3. Enter the coordinates by clicking on the “Define Download Area by Coordinates” as shown by the mouse pointer below:
  4. Click on Modify Data Request, then select either 24K DRG or 24K DRG (California) as appropriate. Of note, you have to wait until the page is finished loading completely before making your selection, then wait until the loading is complete again before clicking “Save Changes and Return to Summary” at the bottom.  If you don't, you will have to go back and Modify Data Request a second time to get the data you wish:
  5. Download the DRG data:
  6. Open the downloaded zip file and extract the TIFF file to a folder for your project. Rename each segment so you can identify it, e.g., JT_1.tif.

Re-Project The Data

In MOAGU, load each TIFF file using the “Load GeoTiff” button.  This will create a geoTIFF that has been reprojected to WGS84 datum, and is named, for example, JT_1_geo.tif.  It will also create a World file (e.g., JT_1_geo.tfw), which has the information about the geographic coordinates for the file.

Prepare The Files For Clean Joins

This is where the largest amount of work has to be put in.  When the GeoTIFF files are re-projected to the WGS84 datum, the file size is enlarged some, and there are roughly triangular shaped black areas around the edge of the _geo.tif file:

In order to create a good join, this area needs to be filled with white (the background color for MOAGU).  If you don't do this, the black area will mar a portion of the adjoining segment.  Unfortunately, the only way I was able to do this involved a moderate amount of Photoshop work (about 20 minutes per segment).  At first glance, it appears you can just select the Paint Bucket Tool in Photoshop and set the foreground color to white.  However, if you do this the black lines on the map that connect to the black edge area will be turned white and erased.  Thus, before you use the Paint Bucket, you have to block off all of the black areas that connect to the black edge using a white rectangle.  Here is the method I used to do this most efficiently:

  1. Zoom to 400% in Photoshop
  2. Start at upper left corner
  3. Select the Rectangle marquee
  4. Foreground color should be set to white
  5. Scan down the left side looking for any black area that connects with the black edge
  6. Place a several pixel wide rectangle that “blocks” this connection
  7. Click on “Edit → Fill → Enter key” to fill the rectangle you just placed with white
  8. Repeat steps 5-7 around the entire periphery of the _geo.tif file
  9. Save the “fixed” _geo.tif file

See an example below:
-->
-->

Create Batch Files To Process

Once you have finished the previous step, you need to have MOAGU create the batch files that will be used by cgsmapper to make the individual IMG file tiles.  I found that processing several files in a row caused MOAGU to create incorrect batch files missing some or all of the needed processing statement.  The bug has been reported to Leszek, and I am sure he will fix it if he can reproduce it.  However, there is a simple workaround:  restart MOAGU before creating the batch file for each piece (the “Create Map Code” button in MOAGU).  The steps are as follows:

  1. Restart MOAGU
  2. Click on “Load Image/World File” button
  3. Select the first _geo.tif file that you edited in the step above (e.g., JT_1_geo.tif)
  4. A dialog comes up asking for the associated World file (e.g., JT_1_geo.tfw)
  5. Make sure Standard USGS Topo is selected
  6. Make sure only the 500 foot zoom level is selected
  7. Enter a map name, e.g., JT_1
  8. Enter a map ID number.  Since MOAGU will create a number of tiles, I found the best thing to do is selected map ID numbers that were 100 apart.  For example, for JT_1 I used 1000100, for JT_2 1000200, etc.  Since the largest number of tiles created for a large piece was 64 tiles, this makes sure that the numbers are unique for each tile of each piece.
  9. Combine points set to Yes (default)
  10. Tile Size set to Large (otherwise, you could end up with too many segments for a large map).
  11. Click on Set Parameters
  12. Click on Create Map Code
  13. Repeat steps 1-12 for each Data File.

MOAGU will take several minutes to chop up your _geo.tif file into a number of “tiles”, which are .mp files.  It also creates a batch file that will run cgsmapper on each tile to create an IMG file.

Process Batch Files with cgpsmapper

While you can process each individual batch file in MOAGU by clicking on the “Compile Map” button, you have to be around to start each compilation.  Since it may take 2-6 hours to process one segment, this is a hassle and requires constant checking to see if a new segment is ready to be processed.  Here is the alternative I used successfully and found most efficient:

  1. Create two files called Overall_1.bat and Overall_2.bat in the same directory as the map data files
  2. In the first batch file, put the following statements to call the individual batch files created in the previous step (without the leading numbers, example shown for Joshua Tree):
    1. Call JT_1.bat
    2. Call JT_2.bat
    3. etc. until you have called half of the batch files
  3. In the second batch file, put the following statements:
    1. Call JT_13.bat
    2. Call JT_14.bat
    3. etc. until you get to the end of the files
  4. Click on Overall_1.bat and Overall_2.bat so they run simultaneously

Result: The batch files will be processed two at a time until they are all finished.  Even with my celeron processor, I found that running one batch file at a time only used about 55% of CPU, while running two batch files simultaneously used about 90% of CPU.  Net result, the batch files processed faster.  For a large project such as the Joshua Tree map, this may take up to a week, depending on number of CPUs in your machine, speed, etc.

Load Tiles into Mapset Toolkit and Create Map for Mapsource

  1. Copy all of the IMG files created in the subdirectories (located in, for example, ...\JT_1_Tiles\500) to the directory you want to use to create the final mapset
  2. Copy one of the .typ files created from one of the subdirectories into the directory you want to use to create the final mapset
  3. Open MapsetToolkit and follow the directions in the MOAGU documentation.  Be sure to check “Install in Mapsource” and “Blank Overview Map”

Check Map in MapSource for Missing Tiles and Reprocess as Needed

Missing tiles are due to either a bug in MOAGU or a problem with cgsmapper (haven't pinned it down yet).

  1. Open MapSource
  2. Select the topo map you created from the dropdown list in the upper left corner, just below the file menu
  3. Zoom to the appropriate level so your map mostly fills the screen
  4. Select the “Map Tool” in MapSource
  5. Click outside upper left corner and drag past lower right corner to select all of the tiles
  6. Look for any areas that don't turn pink (aren't selected).  If there are any, these are missing tiles.

If there are any tiles missing, you can quickly create them as follows:

  1. Identify which segment the tiles are missing from
  2. Copy the _geo.tif and _geo.tfw for that segment to a folder you have temporarily created for that purpose
  3. Open MOAGU and load the _geo.tif and _geo.tfw files using the “Load Image/World Files” button
  4. Use the same settings you used initially, including especially the Map ID Number
  5. Click on Set Parameters
  6. Click on Create Map Code
  7. When Moagu is finished creating the map code, find the batch file that was created in the temporary directory and edit it. 
  8. Delete all of the lines except for the first line, and the line for the tile number you want to reprocess.
  9. Save the batch file, then double click on it to run it
  10. Find the resulting IMG file and copy it to the final directory where all of the other IMG files are located

Now you can take your map and upload it to GPSFileDepot by registering as a member then clicking on Your Account at the top and adding the map so everyone else can use it.