Some Bits: Nelson's log

2 posts in June 2013

Rectangular artifacts in rivers map

Lots of interest in my “all rivers” map, thanks in large part to a post on kottke.org. And several requests for a poster print. I’d like to do that, would be fun to have one for myself, but before I do that I’d want to fix a few things.

The simple thing is to fix the projection, use an Albers USA. It might make sense to use Mike’s code, he’s already got the projection and a nice offline renderer instead of my goofy “screenshot the browser” approach.

The hard thing is to fix these annoying rectangular artifacts in the data. They’re visible in many places, specifically in eastern Oklahoma. I asked the NHDPlus guys and they said the NHD source data was digitized from USGS quads and that some of the quads are different than others, but they couldn’t characterize how. Looking at a zoomed view I think it’s just fewer flowlines; you can see fewer lines on the right than the left.

Taking a suggestion from Seth F I tried to only draw things with a Strahler number > 2; it softens the artifacts, but doesn’t eliminate them. Top is a whole US map, bottom is zoomed in on eastern Oklahoma. Artifacts are still visible. If some quads just have fewer flowlines that’s going to affect the Strahler calculation too. Maybe there’s some other property to filter on to remove the bias, like only rendering things with a gnis_id.

all flowlines, strahler >= 2 rectangular bias

Leaflet GeoJSON vector tiles

Half-finished notes, but I don’t want to lose them.

Leaflet doesn’t have a stock plugin for GeoJSON vector tiles. I believe Glen Robertson’s leaflet-tilelayer-geojson is the most complete and correct plugin, but it renders pretty slowly (several seconds for cached data). My river vector tiles tutorial includes a TileLayer.d3_geoJSON.js that renders about 10x faster, but because it uses D3 instead of Leaflet to do the GeoJSON rendering it lacks full Leaflet integration. For instance, there’s no way to bind a Leaflet popup to a LineString.

Over on the Leaflet-js mailing list I started a discussion “GeoJSON performance? River vector tile map, trying to figure out how to make Glen’s approach using Leaflet GeoJSON faster. Norbert Renner responded with some terrific experimental work that made rendering much faster, but it was sort of a one-off spike rather than a reusable improvement. Someone should spend some time with his optimizations and see if they can be ported to work in the general purpose library.