[gdal-dev] Why gdal_rasterize fails with MBTiles output?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] Why gdal_rasterize fails with MBTiles output?

jratike80

Hi,

 

Captured from gis.stackexchange https://gis.stackexchange.com/questions/264899/create-mbtiles-from-geojson-in-raster-format

 

I made some test data in EPSG:3857 and while GeoTIFF output works fine with GDAL 2.3dev

 

gdal_rasterize -ot Byte  -burn 255 -burn 0 -burn 0 -ts 4950 4950

-of GTiff points_3857.json points_3857.tif -co tiled=yes

0...10...20...30...40...50...60...70...80...90...100 - done.

 

the same command with MBTiles outpur gives me the same error than in the question

 

gdal_rasterize -ot Byte  -burn 255 -burn 0 -burn 0 -ts 4950 4950

-of MBTiles points_3857.json points_3857.mbtiles

ERROR 6: Could not find an appropriate zoom level that matches raster pixel size

 

0...10...20...30...40...50...60...70...80...90...100 - done.

ERROR 6: IWriteBlock() not supported if georeferencing not set

ERROR 6: IWriteBlock() not supported if georeferencing not set

ERROR 6: IWriteBlock() not supported if georeferencing not set

 

So it seems that having geojson as input is not the issue, but having MBTiles as output.

 

-Jukka Rahkonen-

 

 


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Why gdal_rasterize fails with MBTiles output?

Even Rouault-2

Jukka,

 

>

> gdal_rasterize -ot Byte -burn 255 -burn 0 -burn 0 -ts 4950 4950

> -of MBTiles points_3857.json points_3857.mbtiles

> ERROR 6: Could not find an appropriate zoom level that matches raster pixel

> size

 

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.

 

Even

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Why gdal_rasterize fails with MBTiles output?

jratike80
In reply to this post by jratike80

Hi Even,

 

I agree that the first error message says it all and I guessed that the issue was in initializing the output to suit with the tile boundaries. I would also say that the documentation of MBTiles format is not so clear for users who have as little experience as I have, or less.

 

“The driver implements the Create() and IWriteBlock() methods, so that arbitrary writing of raster blocks is possible, enabling the direct use of MBTiles as the output dataset of utilities such as gdalwarp.

 

On creation, raster blocks can be written only if the geotransformation matrix has been set with SetGeoTransform() This is effectively needed to determine the zoom level of the full resolution dataset based on the pixel resolution, dataset and tile dimensions.”

 

In this case also message ERROR 6: IWriteBlock() not supported if georeferencing not set

can make user to believe that there is something wrong with srs of input vectors.

-Jukka-

 

Lähettäjä: Even Rouault [mailto:[hidden email]]
Lähetetty: 18. joulukuuta 2017 13:12
Vastaanottaja: [hidden email]
Kopio: Rahkonen Jukka (MML) <[hidden email]>
Aihe: Re: [gdal-dev] Why gdal_rasterize fails with MBTiles output?

 

Jukka,

 

>

> gdal_rasterize -ot Byte -burn 255 -burn 0 -burn 0 -ts 4950 4950

> -of MBTiles points_3857.json points_3857.mbtiles

> ERROR 6: Could not find an appropriate zoom level that matches raster pixel

> size

 

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.

 

Even

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev