How To Create Garmin Topo Maps - Part 4 - Transportation Data

Author: Dan Blomberg | Last updated November 17th, 2013 at 12:54pm

Introduction

The 4th part of this tutorial details where to get and how to process transporation data.  This includes roads, highways, railroads, ferry routes, and a few other key landmark features (such as major powerlines).  In this tutorial's case we will be getting the most recent, free, roads data available which was released in 2007 and now updated yearly.  The data comes from the U.S. Census Bureau.

Software

Some software is required and some is recommended for downloading and processing transportation data:

Downloading The Transportation Data

The data will come from the U.S. Census Bureau which recently released the Tiger data in shapefile format.

  1. Go to the National TIGER/Line Shapefiles page (will open in new window).
  2. Select download and then web interface.
  3. From the drop down menu on the right select your state.
  4. Transportation data has to be downloaded on a per county basis.  Select the first county from the drop down menu on the right and click "submit"
  5. Create a new folder in your /transportation folder for each county
  6. Click "All Lines" on the left hand side:
  7. Open the zip file
  8. Drag the contents from the zip file to the appropriate county folder in /transportation
  9. Repeat this for all the counties in your state.

Combining The Transportation Data

There are three ways to combine the data, I recommend using FWTools since it is the fastest method and you probably used it for the water data.

FWTools is the fastest and least time consuming way to combine the shapefiles but is slightly more advanced.  It also requires you to have FWTools installed.

  1. Install FWTools and remember its location (normally: C:\Program Files\FWTools2.1.0)
  2. Download the batch files we will need: Merge Transportation Batch File
  3. Extract the file to your transportation folder.
  4. You will need to edit it (right click on the file and click Edit)
  5. On the first line change "C:\your_map_directory\transportation" to match your directory, for example "C:\My Maps\transportation"
  6. On the second line change the C:\Program Files\FWTools2.1.0 if you are using a different version than 2.1.0 or installed it to another location.
  7. Save the files
  8. In your first county's directory take the first shape files and rename them. Take the first tl_20##_#####_edges.shp file and rename it all_lines.shp.  Then rename the dbf, shx, and prj file to all_lines.dbf, all_lines.shx, all_lines.prj. Delete the .shp.xml file.
    Note: If you cannot see the extensions (.dbf, .shp, .shx, etc) do not add the extension, just rename the files all_lines.
  9. Drag the all_lines files to your transportation directory.

Now that our basics are setup will will start combining files.

  1. Open a new Windows Explorer/My Computer window.
  2. Go to the second county folder
  3. Drag the .shp file onto mergetrans.bat in the transportation folder.
  4. Repeat this for all your counties.
  5. Delete all the county folders.

You have now combined all the shapefiles together with FWTools. Contine to Processing The Data.

Global Mapper

Creating the single shapefile in GlobalMapper is a little more resource intensive than using FWTools.  It could take awhile to load the files on your computer.

  1. Open Global Mapper
  2. Click File> Create New Catalog
  3. Save the catalog as transportation
  4. Click Add Directory
  5. Select your transportation direct
  6. in the fields mask put *.shp as shown below:
  7. It will load all the shapefiles, click "Ok"
  8. Now click File>Export Vector Data>Export Shapefile
  9. Check the "Export Lines" box
  10. Save the file as all_lines.shp in your main /transportation folder
  11. You can now delete all the county folders.

GPSMapEdit

Although it is possible to combine the files by opening them all and then saving them as a shapefile I do not reccomend it because it will make processing the data more difficult since you have to "type" them all currently.  I would use the FWTools method over GPSMapEdit.  If you want to do it with GPSMapEdit just select a random type for each line (road would work well) because we will override it when we process the data.

Processing The Transportation Data

As with the water data we will process the transportation data with PostGIS.

Putting The Data In The Database

 A few assumptions are made about your PostGIS setup.  We assume you have a postgis database called postgis. We assume you have a postgres username.

  1. Open PostGIS Shapefile Importer/Exporter
  2. Click view connection details and fill in your database/connection information.
  3. Once you click okay you should see "Connection Succeeded" in the log window.
  4. Click Add File and select the all_lines.shp file
  5. Click import.
  6. If you run into an error follow the steps shown in the log window.  I had to select options and change my type of LATIN1 for some of the files.

The following steps are left here for knowledge and use with PostGIS versions older than 2.0. These steps are not required if you have used the process above.

  1. Open the command prompt (Start>Run>cmd)
  2. Change to the postgresql bin directory normally: C:\Program Files\PostgreSQL8.3\bin use this command: cd "C:\Program Files\PostgreSQL8.3\bin"
  3. We will use the following command to convert the shapefiles to sql files:
    shp2pgsql "C:\your_map_directory\transportation\all_lines.shp" all_lines > all_lines.sql
    Make sure the part in blue points to your actual map directory.
  4. Now that we have a .sql file we need to load it into the database with this commands
    psql -d postgis -h localhost -U postgres -p -f all_lines.sql
    Remove the red -p if your username does not use a password.

 Processing The Data With PostGIS

  1. Open the command prompt (Start>Run>cmd)
  2. Change to the postgresql bin directory normally: C:\Program Files\PostgreSQL\9.3 use this command: cd "C:\Program Files\PostgreSQL9.3\bin"
  3. With the DOS prompt that is still open and hopefully in the PostgreSQL bin folder we will execute a series of queries.
  4. Download the Transportation Queries.
  5. Extract all the file (transportation.sql) to the PostgreSQL bin folder
  6. In the dos prompt run the following commands for each water type:
     psql -d postgis -h localhost -U postgres -p -f transportation.sql
    Remove the red -p if your username does not use a password.
  7. This could take quite a few minutes to run depending on how much data there is (Arizona took just under 30 minutes).

Export Shapefiles From PostGIS

If you are using the PostGIS Shapefile Importer/Exporter you can easily export the files.

  1. Open the PostGIS Shapefile Importer/Exporter
  2. Click add table
  3. Select the all_lines table
  4. Click export and export to your transportation folder.
  5. This will overwrite the current all_lines files.
  6. You can rename all the all_lines files to transportation; this will help match the best of the tutorial.

If you are running an old version of PostGIS and do not have the importer/exporter program you can do this via the command prompts. Your command prompt should still be open to the PostgreSQL bin folder at this time.

  1. Modify and execute the following command.  Make sure the blue points to your transportation directory and remove the -p if your username does not require a password
    pgsql2shp  -f "C:\your_map_directory\transportation\transportation.shp" -u postgres -p postgis all_lines
  2. At this time delete all_lines.sql.
  3. Go to your transportation folder
  4. Rename the following file:
    all_lines.prj --> transportation.prj
  5. Delete all all_lines files.
  6. This should leave you with: transportation.shp, transportation.dbf, transportation.prj, and transportation.shx

Final Data Preparations

Global Mapper

The data is already prepared for use by Global Mapper.  No editing of the shapefiles is needed.

GPSMapEdit

  1. Open your transportation shapefile with GPSMapEdit
  2. On the screen that pops up asking you to select the "type of object" click the "From Field" tab
  3. Scroll until you find the "MP_TYPE" column.
  4. Click on the header to select the column, it should look similar to this:
  5. Click Next
  6. Click the "name" column for naming.
  7. Make sure the datum is NAD83 and click next.
  8. Click finish
  9. Click file> save map as
  10. Name it something useful (like transportation) and save the .mp file in your transportation folder.

What's Next?

Next we will go over getting and processing the points of interest data.  This next lesson should be pretty easy compared to these more challenging ones.

<-- Previous - Water Data | Table Of Contents | Next - Points of Interest -->