Bug report #21958

Problem outputting xyz tiles as MBTiles file

Added by Saber Razmjooei almost 5 years ago. Updated almost 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Processing/QGIS
Affected QGIS version:3.7(master) Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:29773

Description

GDAL/OGR: 2.4.0
QGIS: master

I am trying to create an mbtiles file using xyz tile generator. If the output file is not defined (i.e. not pointing to an existing mbtiles file), I get this:

Traceback (most recent call last):
File "/usr/local/src/QGIS_master/build/output/python/plugins/processing/algs/qgis/TilesXYZ.py", line 335, in processAlgorithm
writer = MBTilesWriter(output_file, tile_params, wgs_extent, min_zoom, max_zoom)
File "/usr/local/src/QGIS_master/build/output/python/plugins/processing/algs/qgis/TilesXYZ.py", line 158, in __init__
ds.ExecuteSQL("INSERT INTO metadata(name, value) VALUES ('{}', '{}');".format('minzoom', min_zoom))
AttributeError: 'NoneType' object has no attribute 'ExecuteSQL'
Execution failed after 0.01 seconds

The algorithm creates an empty mbtiles file. When I run gdalinfo, I get this:

ERROR 1: Cannot find min and max zoom_level
gdalinfo failed - unable to open 'OUTPUT_FILE.mbtiles'.

If I point the output file to overwrite an existing mbtiles, I get this error:

Traceback (most recent call last):
File "/usr/local/src/QGIS_master/build/output/python/plugins/processing/algs/qgis/TilesXYZ.py", line 335, in processAlgorithm
writer = MBTilesWriter(output_file, tile_params, wgs_extent, min_zoom, max_zoom)
File "/usr/local/src/QGIS_master/build/output/python/plugins/processing/algs/qgis/TilesXYZ.py", line 154, in __init__
ds = driver.Create(filename, 1, 1, 1, options=['TILE_FORMAT=%s' % tile_format] + options)
File "/usr/lib/python3/dist-packages/osgeo/gdal.py", line 1736, in Create
return _gdal.Driver_Create(self, *args, **kwargs)
RuntimeError
Execution failed after 0.02 seconds

Associated revisions

Revision b1106b9f
Added by Marcel Dancak almost 5 years ago

[processing] fix #21958 used sqlite3 module instead of GDAL/ORG's SQLite driver

History

#1 Updated by Saber Razmjooei almost 5 years ago

  • Description updated (diff)

#2 Updated by Peter Petrik almost 5 years ago

looks more like sqlite issue, which version do you have?

#3 Updated by Saber Razmjooei almost 5 years ago

3.27.2 2019-02-25 on Ubuntu 19.04

#4 Updated by Saber Razmjooei almost 5 years ago

On Windows, with qgis master:
3.26.0 2018-12-01

#5 Updated by Giovanni Manghi almost 5 years ago

  • Category changed from Processing/Core to Processing/QGIS

#6 Updated by Saber Razmjooei almost 5 years ago

  • Status changed from Open to In Progress
  • Assignee set to Nathan Woodrow

It appears that updating metadata for mbtiles through gdal/ogr sqlite driver is the source of problem. By using python-sqlite3 library, the issue should be resolved hopefully.

#7 Updated by Saber Razmjooei almost 5 years ago

  • Assignee deleted (Nathan Woodrow)
  • Pull Request or Patch supplied changed from No to Yes

#8 Updated by Anonymous almost 5 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

#9 Updated by Peter Petrik almost 5 years ago

  • Resolution set to fixed/implemented

Also available in: Atom PDF