Playing around with a vector river map of California. Some notes.
The Natural Earth major river dataset is pretty good. Not quite detailed enough for the Dreamflows scale map. Also everything looks to be about 2000m north of the natural boundaries defined by counties, other river datasets, etc. Maybe I screwed up a projection?
After a 3 day delay the NHD finally gave me back a shapefile with detailed flowlines for Nevada County. It’s very detailed data but it still has fewer small creeks on it than Google Maps or Stamen Terrain Maps. It might just be seasonal data, or maybe someone has a more detailed set. I need to explore NHDPlus.
Nick was kind enough to give me a shapefile of major rivers in California; 5 meg shapefile, 648 objects. It looks like about the right level of detail for the Dreamflows map, I’m working with it now although I want to circle back to NHD or some other primary source.
To convert a shapefile to GeoJSON:
ogr2ogr -f GeoJSON -t_srs EPSG:4326 dest.json source.shp
This converts the projection to EPSG:4326, the GeoJSON default. It contains ridiculously precise floating point numbers so could use some rounding with LilJSON or the like.
-simplify is useful to minimize the detail in the geometry. The tolerance parameter seems to be in the source CRS, so with this dataset in meters I’m trying “-simplify 100” or the like. 200 meters rounded to 4 digits of lat/lon seems like a good compromise; the rivers aren’t too janky at the scales I care about.
ogr2ogr -f GeoJSON -t_srs EPSG:4326 -simplify 200
python liljson.py -p 4
The resulting GeoJSON file is 200k compressed. Sure takes a long time for Leaflet to draw. For this kind of application I really want tiled, variable resolution vector data. Polymaps supported that years ago but it was complicated and underutilized. I wonder if anyone’s done it in Leaflet? May be overkill if I can make a Dreamflows-specific vector dataset.
Here’s a QGIS image of a bunch of different data sources showing northwestern Nevada County. Pink dot is my house, center of the map is Deer Creek running west of Nevada City down to the Yuba. This data set is missing local reservoirs and ponds. Thick green line is Natural earth data, thick blue line is Nick’s rivers, and spidery blue lines are the N HD detailed data. Black line is the county border.
And here’s a snapshot of the Dreamflows map I made a few days back with vector rivers overlaid. I like how it highlights the river flows to put the gauge dots in context. But I need a better data source; this one has many rivers that aren’t relevant to the map, and other rivers like Cache Creek and Antelope Creek are missing. I probably should cherry-pick just the rivers that I have gauge data for.