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:

On the first line change "C:\your_map_directory\transportation" to match your directory, for example "C:\My Maps\transportation"

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.

Save the files

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.

Drag the all_lines files to your transportation directory.

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

Open a new Windows Explorer/My Computer window.

Go to the second county folder

Drag the .shp file onto mergetrans.bat in the transportation folder.

Repeat this for all your counties.

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.

Open Global Mapper

Click File> Create New Catalog

Save the catalog as transportation

Click Add Directory

Select your transportation direct

in the fields mask put *.shp as shown below:

It will load all the shapefiles, click "Ok"

Now click File>Export Vector Data>Export Shapefile

Check the "Export Lines" box

Save the file as all_lines.shp in your main /transportation folder

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.

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.

Now that we have a .sql file we need to load it into the database with this commandspsql -d postgis -h localhost -U postgres -p -f all_lines.sql
Remove the red -p if your username does not use a password.

Extract all the file (transportation.sql) to the PostgreSQL bin folder

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.

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.

Open the PostGIS Shapefile Importer/Exporter

Click add table

Select the all_lines table

Click export and export to your transportation folder.

This will overwrite the current all_lines files.

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.

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 passwordpgsql2shp -f "C:\your_map_directory\transportation\transportation.shp" -u postgres -p postgis all_lines

At this time delete all_lines.sql.

Go to your transportation folder

Rename the following file:
all_lines.prj --> transportation.prj

Delete all all_lines files.

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

Open your transportation shapefile with GPSMapEdit

On the screen that pops up asking you to select the "type of object" click the "From Field" tab

Scroll until you find the "MP_TYPE" column.

Click on the header to select the column, it should look similar to this:

Click Next

Click the "name" column for naming.

Make sure the datum is NAD83 and click next.

Click finish

Click file> save map as

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.