How To Create Garmin Topo Maps - Part 3 - Water DataLast updated May 29th, 2008 at 02:55pm Introduction
This part details how to download high resolution water data from the USGS NHD database. After we download the data we will learn how to process it rapidly via postGIS to get rid of parts we don't want and make it very easy for global mapper or GPSMapEdit to process.
Note: When originally writing this and making maps you were able to download entire quads; that has changed recently and only subbasins can be downloaded. This makes the process slightly more difficult.
Software
Some software is required and some is reccomended for downloading and processing water data:
- Downloading
- High speed internet (don't even try it with dialup)
- Modern browser (IE 6, IE 7, Firefox 2+, Safari 3+, Opera 8+, etc)
- An email account
- Processing
- PostGIS & PostgreSQL server (free/open source) (Install/Setup Tutorial)
- FWTools - allows for rapid shapefile combining (optional) (free/open source)
- Global Mapper - the postGIS files will be modified to work very easily in Global Mapper (free demo/expensive)
- GPSMapEdit - can also read the files which will be modified by postGIS (free demo/cheaper)
Downloading The Data
- Open the excel spreadsheet you downloaded from here.
- Go to the NHD Geodatabase Viewer
- Click "Zoom To State" on the left side.

- Select your state and let the viewer reload.
- On the right side - click on "Base Map Features"
- Now click the check box next to 100k Quad Index. This will display your 100k Quads
- On the right side - click on "Hydrologic Units"
- Now make sure the check box is set for Subbasins and click the radio button for subbasins. This will make subbasins your active layer. Your right side should look like this:

- On the left side click the "Polygon Extract" tool
- Drag a box to select the subbasins in your first 100k quad. A popup will appear at this point and list all the subbasins you've selected. You can only have 10 listed. If you have more than 10 close the popup and create a new smaller box.
Note: If a window did not pop up make sure your pop-up blocker is set to allow pop-ups from all usgs.gov addresses (*.usgs.gov).
- The top lists the subbasins you have selected. These will be larger than the 100k quad index; the map will have them highlighted
- Select "High Resolution" in the next section section. In the third section select "Shapefile". Enter your email address in the final blank. It should look similar to this:

- Click "extract"
- When the emails arrive just download the file and extract it to your nhd folder (keep each zip file in their own NHD###### folder).
- Repeat these steps until you have selected all the subbasins for you area. This took 8 emails for the entire state of Mississippi. Try not to repeat subbasins too many times.
Combining The Data
Each file you received from the NHD will have a seperate folder containing the files we need: NHDArea.shp, NHDFlowline.shp, and NHDWaterbody.shp. We need to combine all the files we have into a single set of shapefiles that can then be quickly processed. There are a few ways to do this.
FWTools
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.
- Install FWTools and remember its location (normally: C:\Program Files\FWTools2.1.0)
- Download the three batch files we will need: Merge NHD Data Batch Files
- Extract all three files to your nhd folder.
- You will need to edit each one (right click on the file and click Edit)
- On the first line change "C:\your_map_directory\nhd" to match your directory, for example "C:\My Maps\nhd"
- 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 all three files
Now that our basics are setup will will start combining files. You will repeat this for each type "Waterbody, Area, and Flowline"
- Go to the first NHD###### folder and then into the hydrography folder; copy the following files to your nhd folder (the base folder with the three bat files) for each type:
- Flowlines - NHDFlowline.dbf, NHDFlowline.prj, NHDFlowline.shp, NHDFlowline.shx
- Area - NHDArea.dbf, NHDArea.prj, NHDArea.shp, NHDArea.shx
- Waterbody - NHDWaterbody.dbf, NHDWaterbody.prj, NHDWaterbody.shp, NHDWaterbody.shx
- Your nhd folder should look similar to this now:

- Now open another "My Computer" or "Windows Explorer" and browse to the /nhd folder.
- For each NHD###### folder (except the first one) go into it and then take NHDArea.shp and drag it to the other window and onto "mergearea.bat". Drag each NHDFlowline.shp onto "mergeflowline.bat". Finally, drag each NHDWaterbody.shp onto "mergewaterbody.bat".
- Repeat this for all the NHD###### folders you have.
You have now combined all the shapefiles together with FWTools. Contine to Processing The Data.
Global Mapper
- Open Global Mapper
- For the areas:
- Open the first NHDArea.shp file in the first NHD######
- Now open all the other NHDArea.shp files in each individual NHD###### folder.
- Click File>Export Vector Data>Export Shapefile
- Check the "Export Areas" box
- Save the file as NHDArea.shp in your main /nhd folder
- For the flowlines:
- Open the first NHDFlowline.shp file in the first NHD######
- Now open all the other NHDFlowline.shp files in each individual NHD###### folder.
- Click File>Export Vector Data>Export Shapefile
- Check the "Export Lines" box
- Save the file as NHDFlowlines.shp in your main /nhd folder
- For the waterbodies:
- Open the first NHDWaterbody.shp file in the first NHD######
- Now open all the other NHDWaterbody.shp files in each individual NHD###### folder.
- Click File>Export Vector Data>Export Shapefile
- Check the "Export Areas" box
- Save the file as NHDWaterbody.shp in your main /nhd folder
You have now combined all the shapefiles together with Global Mapper. Contine to Processing The Data.
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 area and line because we will override it when we process the data.
Processing The Data
Although GPSFileDepot has an article detailing how to process the water data already this tutorial will vary slightly because if you have followed the steps so far all the files are premade for you. We will use PostGIS for the processing.
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.
- Open the command prompt (Start>Run>cmd)
- Change to the postgresql bin directory normally: C:\Program Files\PostgreSQL\8.3\bin use this command: cd "C:\Program Files\PostgreSQL\8.3\bin"
- We will use the following command to convert the shapefiles to sql files:
- Areas - shp2pgsql "C:\your_map_directory\nhd\NHDArea.shp" NHD_Area > nhd_area.sql
Make sure the part in blue points to your actual map directory.
- Flowlines- shp2pgsql "C:\your_map_directory\nhd\NHDFlowline.shp" NHD_Flowline > nhd_flowline.sql
Make sure the part in blue points to your actual map directory.
- Waterbody- shp2pgsql "C:\your_map_directory\nhd\NHDWaterbody.shp" NHD_Waterbody > nhd_waterbody.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 commands:
- Areas - psql -d postgis -h localhost -U postgres -p -f nhd_area.sql
Remove the red -p if your username does not use a password.
- Flowlines - psql -d postgis -h localhost -U postgres -p -f nhd_flowline.sql
Remove the red -p if your username does not use a password.
- Waterbody - psql -d postgis -h localhost -U postgres -p -f nhd_waterbody.sql
Remove the red -p if your username does not use a password.
Now that the data is loaded we will start processing it. You can do this with pgAdmin III (as shown in this tutorial) but we have provided a zip file with all the queries to make life easier.
Processing The PostGIS Data
- With the DOS prompt that is still open and hopefully in the PostgreSQL bin folder we will execute a series of queries.
- Download the NHD queries.
- Extract all three files to the PostgreSQL bin folder
- In the dos prompt run the following commands for each water type:
- Areas - psql -d postgis -h localhost -U postgres -p -f area_sql.txt
Remove the red -p if your username does not use a password.
- Flowlines - psql -d postgis -h localhost -U postgres -p -f flowline_sql.txt
Remove the red -p if your username does not use a password.
- Waterbody - psql -d postgis -h localhost -U postgres -p -f waterbody_sql.txt
Remove the red -p if your username does not use a password.
This has processed all the data and given it appropriate MP_TYPES.
Export Shapefiles From PostGIS
Your command prompt should still be open to the PostgreSQL bin folder at this time.
- Modify and execute the following commands. Make sure the blue points to your nhd directory and remove the -p if your username does not require a password
- Areas - pgsql2shp -f "C:\your_map_directory\nhd\Area.shp" -u postgres -p postgis nhd_area
- Flowlines - pgsql2shp -f "C:\your_map_directory\nhd\Flowline.shp" -u postgres -p postgis nhd_flowline
- Waterbody - pgsql2shp -f "C:\your_map_directory\nhd\Waterbody.shp" -u postgres -p postgis nhd_waterbody
- At this time delete nhd_area.sql, nhd_flowline.sql, and nhd_waterbody.sql.
- Go to your nhd folder
- Rename the following files:
- NHDArea.prj --> Area.prj
- NHDFlowline.prj --> Flowline.prj
- NHDWaterbody.prj --> Waterbody.prj
- Delete all NHDArea, NHDFlowline, and NHDWaterbody files.
- This should leave you with a set of files similar to this:

Final Data Preparations
Global Mapper
The data is already prepared for use by Global Mapper. No editing of the shapefiles is needed. Just make sure you have all three shapefiles in your nhd folder. At this time you can also delete/archive the old files and the NHD###### folders.
GPSMapEdit
- Open your first 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.
- Click next at the datum and bounds screen.
- Click finish
- Click file> save map as
- Name it something useful and save the .mp file in your nhd folder.
- Repeat this process for all three water types and you'll be good to go.
What's Next?
Next we will go over getting and processing the transportation data including roads, railroads, highways, and a few "odd" lines such as powerlines and ferry routes.
<-- Previous - Elevation Data | Table Of Contents | Next - Transportation --> |