Rendering Spatial Data Without Having to Generalize Beforehand

Yesterday I posted about Chris Hogan’s walk-through of generalizing data in PostGIS to make it usable in a web app.  Basically he went through the process of finding out what is the sweet spot of quality vs speed.  But there are other ways to accomplish this.  Mapbox happened to post about a new library called geojson-vt.

Let’s see if Mapbox GL JS can handle loading a 106 MB GeoJSON dataset of US ZIP code areas with 33,000+ features shaped by 5.4+ million points directly in the browser (without server support):

Wait, what?! A few seconds loading the data, and you can browse the whole data set smoothly and seamlessly. But how exactly does that work? Let’s find out

So that’s actually pretty amazing.  We all know what GeoJSON does in the browser and how it impacts the speed of maps drawing.  100 MB+ data rendering so quickly?  Impressive.  Read the whole post to see how they do it and the details on how to start using it.  The only limitation is that it requires mapbox-gl-js or
Mapbox Mobile[footnote]which is actually a big limitation if you think about it[/footnote].
 UPDATE: Per Tom MacWright:

Mapbox-GraphicStill this comes down to using tools that make your mapping products better.  Maybe Mapbox does that cheaper and quicker than you could on your own.  This kind of on-the-fly simplification is what we’ve all been asking for and Mapbox is really pushing the envelope.  This could be what gets people to start using their platform.

Simply GIS

I had some endpoints of a lines that I needed to convert to GeoJSON today.  Before I started I do what every GIS professional does, take inventory of the multitude of ways to actually accomplish this.  I mentally jotted down the following:

  • Esri ArcGIS
  • QGIS
  • Online tools (csv -> json)
  • R
  • Python

I started to realize that these are all pretty heavy tools to just accomplish something as simple as a line string to line.  We literally pull out a chainsaw when all we want it to trim a little piece of paper.  Nothing simple about converting some coordinates into JSON.  Enter Turf.js.

turf.linestring – Creates a LineString based on a coordinate array. Properties can be added optionally.

turfjsSo simple, plus it’s JavaScript already.  Honestly I need to keep coming back to Turf.js, the docs cover easily 90% of what we mostly do with GIS every day.  I just run Turf.js on my laptop and now I don’t even have to open up QGIS to get my work done.  The best part, all JavaScript!  So who is writing the Turf.js book right now?

GeoJSON Updates

Looks like GeoJSON got a new home on the Internet.’

//platform.twitter.com/widgets.jsNot only that, GeoJSON has a new GitHub home.

If you search Twitter for GeoJSON you see how much awesome is being done with it. Heck, even OGC wants to get in on that action (for good or bad).