Create MBTiles from geojson in raster format

There is an answer in gdal-dev mailing list https://lists.osgeo.org/pipermail/gdal-dev/2017-December/047904.html.

The error message says it all, doesn't it ? MBTiles only accepts a single tiling scheme, with a pre-defined set of zoom levels / resolutions. By default, when gdal_rasterize will initialize the output raster, the chance that it fits to those constraints is extremely unlikely.

Now you may wonder why you can gdal_translate an arbitrary raster as MBTiles. This is because MBTiles (similarly to GeoPackage with a predefined tiling scheme) sheat in its CreateCopy() implementation to invoke the warping engine to reproject/resample to one of the compatible zoom level.

But gdal_rasterize use the Create() interface, so this isn't possible.

Obvious workaround: rasterize to TIF and translate to MBTiles.

It seems to be possible to make gdal_rasterize to write directly into MBTiles file if the resolution matches the tiling schema. I guess that it is possible to solve the resolution mathematically but I just made the initial conversion into TIFF, then into MBTiles, and then I checked with gdalinfo what the pixel size is. With the same pixel size this command did create a MBTiles file despite the error about min and max zoom_level.

gdal_rasterize -ot Byte  -burn 255 -burn 0 -burn 0 -tr 9.55462853
5647032 9.554628535647032 -of MBTiles points_3857.json points_3857_2.mbtiles
ERROR 1: Cannot find min and max zoom_level
0...10...20...30...40...50...60...70...80...90...100 - done.