1

I am trying to use GDAL 2.2.2 and the gdal_polygonizecommand to convert a TIF into vector MBtiles from the link:

https://github.com/geostarters/gdal_snipets

I run the following command on the tif as in the link:

gdal_polygonize.py -8 -nomask -b 1 input_4326.tif \
-f "MBTiles" output.mbtiles \
-lco NAME=nameoutput \
-dsco WRITE_BOUNDS=YES \
-dsco MAX_FEATURES=20000000 \
-dsco MAXZOOM=15

However I get the following ERROR:

Traceback (most recent call last): File "/usr/bin/gdal_polygonize.py", line 180, in dst_ds = drv.CreateDataSource( dst_filename ) AttributeError: 'NoneType' object has no attribute 'CreateDataSource'

It seems to me that I do not have the GDAL MBTiles Driver 'installed':

https://gdal.org/drivers/raster/mbtiles.html

I installed gdal onto Uubntu 16.04 via the terminal.

Is there anything I can do to get this working?

1
  • 1
    You can test if you have the driver with ogrinfo --format mbtiles. – user30184 Jan 26 at 19:14
1

Your main problem is that your GDAL version 2.2.2 is too old for creating MBTiles vector dataset. You must upgrade.

From the MBTiles documentation https://gdal.org/drivers/raster/mbtiles.html

Starting with GDAL 2.3, the MBTiles driver has read and write support for MBTiles vector datasets. For standalone Mapbox Vector Tile files or set of MVT files, see the MVT driver. Note: vector write support requires GDAL to be built with GEOS.

You may be hit by some other problems even with a proper GDAL version. I made a test with GDAL 3.1.4 and the following command worked for me:

gdal_polygonize.py -8 -nomask -b 1 P4433H.tif -f "MBTiles" output.mbtiles -lco NAME=nameoutput

By the documentation WRITE_BOUNDS is only for raster tiles. MAXZOOM and MAX_FEATURES should be OK to use but I had to drop them as well.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.