TransWikia.com

Using GDAL ogr2ogr correctly to generate vector MVT tiles

Geographic Information Systems Asked on October 8, 2020

I am a bit lost here. I am trying to convert JSON to MVT tiles for Mapbox (directory format) using ogr2ogr. My problem is that no matter what I do on the Mapbox/browser side, the tiles do not show up. I am thinking I am generating the tiles wrong.

What I have is weather radar data, which looks like this in the JSON file :

   {
    "type": "Feature",
    "geometry": {      "type": "Polygon",
      "coordinates": [
        [
          [-86.78203526482261, 33.14694835752057],
          [-86.7860454984611, 33.13859751774804],
          [-86.78673620526779, 33.138838036230396],
          [-86.78255333547662, 33.1471287631669],
          [-86.78203526482261, 33.14694835752057]
        ]
      ]
     },
     "properties": {
        "value": 18.0,
        "colorIndex": 6
     }
   }

I see documentation for doing this at : https://gdal.org/drivers/vector/mvt.html. Here is the command I have used :

ogr2ogr -f MVT -dsco FORMAT=DIRECTORY -dsco MAXZOOM=10 target.mbtiles test.geojson

I am not sure what -dsco means and I can’t find it in the documentation, but the script runs with it.

The output generates tiles in directories like I would expect it to look, but it will never load on a map.

Is there something wrong with the way I am converting the data? Something I am missing? I am not an expert here so I think that might be the problem. I am sure it’s not a projection issue as the default settings are in EPSG:3857. Any help is greatly appreciated.

One Answer

I find the solution in the page http://osgeo-org.1560.x6.nabble.com/gdal-dev-driver-MVT-no-tiles-generated-td5367086.html

In the conversation, it mentioned that GDAL MVT can not generate the tiles but only the metadata.js because the polygons in the source GeoJson were Polygon Z. The GADL MVT driver currently is only capable of dealing with x y geometry.

Then I went back to check the shape type of my data and found that mine is multipolygon. Problem solved after converting the data to polygons in QGIS.

Here is the command line I used. ogr2ogr -f MVT ./data/tiles ./data/simple.geojson -dsco MINZOOM=0 -dsco MAXZOOM=10

Answered by lang sun on October 8, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP