Minimal: Major Rivers of the United States Minimal: Major Rivers of US
Vector Tiles vs. GeoJSON
If you've ever tried loading half a million features on a web map, you know how slow it gets. This dataset has 468,892 river segments (3,084 unique rivers), and the raw GeoJSON version was 621 MB. That's a 10+ second wait and over 150 MB of memory just to see the map.
Vector tiles fix that. Instead of sending everything at once, they break the data into smaller tiles by zoom level, so your browser only pulls what you're actually looking at. The same dataset drops to about 2 seconds of load time and 15-20 MB of memory, with smooth performance even on mobile.
The Workflow
The rivers were pulled from PostGIS using NHD flowlines filtered for names containing "River," then uploaded to Mapbox's tiling service to build the tile pyramid. Mapbox handles simplification at each zoom level, caching, and delivery through its CDN.
Here's the ogr2ogr command used to extract the data from PostGIS:
ogr2ogr -f "GeoJSON" \
"day-11-rivers-filtered.geojson" \
"PG:host=localhost port=5432 dbname=gis user=postgres" \
-sql "SELECT gnis_id, gnis_name, lengthkm, geom
FROM nhdflowline
WHERE gnis_name LIKE '%River%'
AND gnis_name IS NOT NULL" \
-t_srs EPSG:4326 In short, vector tiles load 5-7x faster, use about 90% less memory, and are what every serious mapping platform uses once you're dealing with more than a few thousand features.
Why River Segments Instead of Whole Rivers?
The National Hydrography Dataset uses stream segments (called flowlines or reaches) rather than whole rivers. This isn't arbitrary. It's designed for network analysis, data integration, and hydrologic modeling.
Network connectivity: Each segment has explicit upstream and downstream relationships. You can trace how a toxic spill in one segment affects everything downstream, or model fish migration patterns through the network.
Data integration: The NHD acts as an addressing system for surface water. Streamgage data, water quality measurements, and habitat information from different organizations all reference the same segment IDs. This lets you combine datasets from USGS, EPA, state agencies, and universities without maintaining separate geospatial layers.
Detailed modeling: NHDPlus HR connects each stream segment to its catchment area (the landscape draining into it). You can link land cover, slope, and precipitation data to specific segments for flow estimation and pollution modeling.
Data management: Breaking rivers into segments makes updates manageable. State and local programs can edit their sections without touching the entire dataset. You update what changed, not the whole river.
Performance: Working with discrete segments is computationally faster than managing continuous river lines, especially for network analysis at local scales.
While we visualize rivers as continuous features, the segmented data model provides the structure for advanced analysis and data sharing across organizations.
Data Source
USGS National Map - National Hydrography Dataset