How To Create Garmin Topo Maps - Part 3 - Water Data

Author: Dan Blomberg | Last updated January 16th, 2016 at 01:15pm

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 this tutorial was updated in 2016 the USGS created a new, easier method to acquire the NHD data.  While the old map viewers and processes still exist this tutorial has been completely converted over to the USGS National Map method.

Downloading The Data 

  1. Open the National Map Viewer (Download version)
  2. First, on the left side select "Hydrography (NHD) and Watersheds (WBD)"
  3. Make sure the "National Hydrography Dataset (NHD) Best Resolution" box is checked
  4. For file format select "Shapefile"
  5. For Data Extent select "State"
  6. Use the map on the right to zoom until you can see your entire state.
  7. Check the "Map Indices" button and select 1 Degree (this will allow you to see each grid that must be downloaded).
  8. Now use the "Draw Point" function to draw a point in the state you want the data for.
  9. With the point drawn click Find Products in the left pane.
  10. Download the file for your state.
  11. Extract all the files from the zip file into your water (nhd) folder.
  12. You are now ready to process the data.

Processing The Data

We will use PostGIS to process all the water data.  With the more recent versions of PostgreSQL and postgis this has gotten more user friendly.

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 pgadmin III (in the start menu)
  2. Double click the PostgreSQL database to connect to it. Enter the password if required.
  3. Expand databases
  4. Click on postgis to access/initialize that database.
  5. Expand postgis
  6. Expand Schemas
  7. Expand public
  8. Expand Tables
  9. Make sure that you don't currently have nhdarea, nhdflowline, or nhdwaterbody tables. If you do, right click each one and select Delete/Drop
  10. Now go to the Plugins menu and select "PostGIS Shapefile and DBF Loader 2.2"
  11. In the Import tab click "Add File"
  12. Select the NHDArea.shp file and click Open
  13. Click "Add File" again
  14. Select the NHDFlowline.shp file and click Open
  15. Click "Add File" again
  16. Select the NHDWaterbody.shp file and click Open
  17. Click Import
  18. Close the PostGIS Shapefile Import/Export manager.

Now that the data is loaded we will start processing it.

Processing The PostGIS Data

  1. Still in pgAdmin III right click on tables and select refresh.
  2. You should now see three new tables: nhdarea, nhdflowline, nhdwaterbody
  3. Click the SQL query button.
  4. Put the following query into the SQL editor box:
    ALTER TABLE nhdarea ADD COLUMN MP_TYPE character varying(50);
    ALTER TABLE nhdarea ALTER COLUMN MP_TYPE SET STORAGE EXTENDED;
    ALTER TABLE nhdarea RENAME COLUMN gnis_name TO name;
    DELETE FROM nhdarea WHERE fcode = '53700' or fcode = '30700' or fcode = '31800' or fcode = '34300' or fcode = '34305' or fcode = '34306' or fcode = '36400' or fcode = '37300' or fcode = '56800' or fcode = '43100' or fcode = '45400' or fcode = '45401' or fcode = '45402' or fcode = '45403' or fcode = '45404' or fcode = '46100' or fcode = '48500' or fcode = '40300' or fcode = '40307' or fcode = '40308' or fcode = '40309';
    UPDATE nhdarea SET MP_TYPE = '0x28' WHERE fcode = '31200' or fcode='44500';
    UPDATE nhdarea SET MP_TYPE = '0x49' WHERE fcode = '33600' or fcode = '33601' or fcode = '33602'; 
    UPDATE nhdarea SET MP_TYPE = '0x3b' WHERE fcode = '36200' or fcode='39800' or fcode='45500';
    UPDATE nhdarea SET MP_TYPE = '0x49' WHERE fcode = '46000' or fcode = '46006';
    UPDATE nhdarea SET MP_TYPE = '0x46' WHERE (fcode = 46000 or fcode = 46006) and areasqkm >= 15;
    UPDATE nhdarea SET MP_TYPE = '0x47' WHERE (fcode = 46000 or fcode = 46006) and areasqkm >= 10 and areasqkm < 15;
    UPDATE nhdarea SET MP_TYPE = '0x48' WHERE (fcode = 46000 or fcode = 46006) and areasqkm >= 2 and areasqkm < 10;
    UPDATE nhdarea SET MP_TYPE = '0x4c' WHERE fcode = '46003' or fcode='48400';
    DELETE FROM nhdarea WHERE MP_TYPE IS NULL;
  5. Click execute query
  6. Close the SQL window.
  7. Click the SQL query button.
  8. Put the following query into the SQL editor box:
    ALTER TABLE nhdflowline ADD COLUMN MP_TYPE character varying(50);
    ALTER TABLE nhdflowline ALTER COLUMN MP_TYPE SET STORAGE EXTENDED;
    ALTER TABLE nhdflowline RENAME COLUMN gnis_name TO name;
    DELETE FROM nhdflowline WHERE fcode = '33600' or fcode = '33601' or fcode = '33602' or fcode = '42000' or fcode = '33400';
    DELETE FROM nhdflowline WHERE fcode >= '42800' and fcode <= '42850';
    UPDATE nhdflowline SET MP_TYPE = '0x18' WHERE fcode = '55800' or fcode = '46000' or fcode = '46006';
    UPDATE nhdflowline SET MP_TYPE = '0x15' WHERE fcode = '56600';
    UPDATE nhdflowline SET MP_TYPE = '0x26' WHERE fcode = '46003';
    DELETE FROM nhdflowline WHERE MP_TYPE IS NULL;
  9. Click execute query.
  10. Close the SQL window.
  11. Click the SQL query button.
  12. Put the following query into the SQL editor box:
    ALTER TABLE nhdwaterbody ADD COLUMN MP_TYPE character varying(50);
    ALTER TABLE nhdwaterbody ALTER COLUMN MP_TYPE SET STORAGE EXTENDED;
    ALTER TABLE nhdwaterbody RENAME COLUMN gnis_name TO name;
    DELETE FROM nhdwaterbody WHERE fcode >='43600' AND fcode <='43626';
    UPDATE nhdwaterbody SET MP_TYPE = '0x4d' WHERE fcode = '37800';
    UPDATE nhdwaterbody SET MP_TYPE = '0x40' WHERE fcode = '49300';
    UPDATE nhdwaterbody SET MP_TYPE = '0x41' WHERE fcode = '39000' OR fcode = '39004' OR fcode = '39009' OR fcode = '39010' OR fcode = '39011' OR fcode = '39012';
    UPDATE nhdwaterbody SET MP_TYPE = '0x40' WHERE (fcode = '39004' OR fcode = '39009' OR fcode = '39010' OR fcode = '39011' OR fcode = '39012') and areasqkm >= 0.25 and areasqkm < 11;
    UPDATE nhdwaterbody SET MP_TYPE = '0x3f' WHERE (fcode = '39004' OR fcode = '39009' OR fcode = '39010' OR fcode = '39011' OR fcode = '39012') and areasqkm >= 11 and areasqkm < 25;
    UPDATE nhdwaterbody SET MP_TYPE = '0x3e' WHERE (fcode = '39004' OR fcode = '39009' OR fcode = '39010' OR fcode = '39011' OR fcode = '39012') and areasqkm >= 25 and areasqkm < 77;
    UPDATE nhdwaterbody SET MP_TYPE = '0x3d' WHERE (fcode = '39004' OR fcode = '39009' OR fcode = '39010' OR fcode = '39011' OR fcode = '39012') and areasqkm >= 77 and areasqkm < 250;
    UPDATE nhdwaterbody SET MP_TYPE = '0x3c' WHERE (fcode = '39004' OR fcode = '39009' OR fcode = '39010' OR fcode = '39011' OR fcode = '39012') and areasqkm >= 250 and areasqkm < 600;
    UPDATE nhdwaterbody SET MP_TYPE = '0x44' WHERE (fcode = '39004' OR fcode = '39009' OR fcode = '39010' OR fcode = '39011' OR fcode = '39012') and areasqkm >= 600 and areasqkm < 1100;
    UPDATE nhdwaterbody SET MP_TYPE = '0x43' WHERE (fcode = '39004' OR fcode = '39009' OR fcode = '39010' OR fcode = '39011' OR fcode = '39012') and areasqkm >= 1100 and areasqkm < 3300;
    UPDATE nhdwaterbody SET MP_TYPE = '0x42' WHERE (fcode = '39004' OR fcode = '39009' OR fcode = '39010' OR fcode = '39011' OR fcode = '39012') and areasqkm >= 3300;
    UPDATE nhdwaterbody SET MP_TYPE = '0x4c' WHERE fcode = '39001' OR fcode = '39005' OR fcode = '39006';
    UPDATE nhdwaterbody SET MP_TYPE = '0x51' WHERE fcode = '46600';
    UPDATE nhdwaterbody SET MP_TYPE = '0x53' WHERE fcode = '36100';
    DELETE FROM nhdwaterbody WHERE MP_TYPE IS NULL;
  13. Click execute query.
  14. Close the SQL window.

This has processed all the data and given it appropriate MP_TYPES.

Export Shapefiles From PostGIS

  1. With pgAdmin III still open go to the Plugins menu and select "PostGIS Shapefile and DBF Loader 2.2"
  2. Click the export tab
  3. Click "Add Table"
  4. Select nhdarea, nhdflowline, and nhdwaterbody (hold ctrl to select them all at once) and click OK
  5. Click "Export"
  6. Go to the folder where your NHD data is stored and click "Open". This will overwrite the old NHD data and replace it with the modified data.
  7. Once the export is complete close the Loader
  8. To save space and not make a mistake later, in pgAdmin III delete each table. Right click on nhdarea and click Delete/Drop. Right click on nhdflowline and click Delete/Drop. Right click on nhdwaterbody and click Delete/Drop.
  9. In that folder you can now delete everything that isn't a NHDArea, NHDFlowline, or NHDWaterbody file (keep those names with .dbf, .prj, .shp, and .shx)

Final Data Preparations

Global Mapper

We will clip the data to the state border now.

  1. First open GU_StateOrTerritory (from back in Setup/Part 1) in Global Mapper
  2. Now open the nhdarea, nhdflowline, and nhdwaterbody shapefiles in Global Mapper
  3. Click the digitizer tool (pencil)
  4. Select the state (not any of the water data; try to find a blank spot and click there; you may have to zoom in on the blank spot to really hit a blank spot)
  5. Right click on the state and select "Crop/Combine/Split Functions" then "CROP - Crop Loaded Features to Selected Area(s)"
  6. Check the "Mark Cropped Features Deleted"
  7. Click OK. This will take some time (NOTE: QGIS' clip function appears faster so if time is a concern it may be worth switching programs for this portion).
  8. Open the Control Center and close the GU_StateOrTerritory overlay
  9. Click File>Export Vector Data>Export Shapefile...
  10. In the shapefile export options window check the box for Export Areas and then call the file nhdareawaterbodyfinal.
  11. Now check the box for Export Lines and then call the file nhdflowlinefinal
  12. Click "OK"
  13. Close Global Mapper.

GPSFDshp2mp & QGIS

We will clip the water data so it ends at the state boundary.

  1. Open QGIS
  2. Add the nhdarea, nhdflowline, and nhdwaterbody shapefiles by going to Layer > Add Layer > Add Vector Layer...
  3. Add the vector layer GU_StateOrTerritory.shp file modified back in part 1 (Layer > Add Layer > Add Vector Layer...)
  4. Go to Vector > Geoprocessing Tools > Clip
  5. For the input layer select nhdarea and for the clip layer select GU_StateOrTerritory
  6. For output file hit Browse and call the file nhdareafinal
  7. Click OK. This could take a long time so be patient.
  8. Repeat steps 5-7 for nhdflowline and nhdwaterbody calling them nhdflowlinefinal and nhdwaterbodyfinal

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 -->