[GIS] Converting Mapbox Vector Tiles To GeoJSON

mapboxnode-jsturfvector-tiles

I'm working on a project that needs to do some simple turf.js work on the client. I am using Mapbox to host my GeoJSON data. Mapbox serves the client this data as a vector tile set, which saves a lot on bandwidth and load times on the client for large datasets. Unfortunately turf.js only works with GeoJSON, not Mapbox Vector Tiles. As far as I know, there are two libraries that can convert vector tiles into GeoJSON: vt-geojson, and vector-tile-js. The problem with these libraries is that they are Node.js libraries, not browser javascript.

At this point it seems I have four options:

  • Convert one of these libraries to normal javascript (and spend time doing it)
  • Add Browserify to my project to convert it for me (and messy up my project)
  • Find some other javascript library that can do it for me (and maybe not find one)
  • Write my own library (and spend lots of time and effort)

I'm hoping that someone on here can help me with the third option, finding a JS library.

Best Answer

I think you're out of luck, there is no third option. I cannot claim this with 100% certainty, but I'm at the moment doing an extensive research about vector tiling, and in short MapBox vector tiles are optimized for presentation for their own rendering engine. So while open, it is more or less proprietary - and from this perspective it is probably best to stick closely to MapBox libraries (stability and quality when dealing with these vector tiles).

So I'd say it's best to stick with vt-geojson. But I think you could also open a feature request on Github. This sounds like a useful feature.