I've noticed similar issues with the plug in to mine but the answer given also lead to the same Math Domain Error. I do want to be in the same projection. I have tried changing the extent to '-180.000000000,180.000000000,-89, 89 [EPSG:4326]' which was given on a previous post but it also gave the error.

What can I do to fix this:

QGIS version: 3.32.1-Lima QGIS code revision: 4a078ecf63 Qt version: 5.15.3 Python version: 3.9.5 GDAL version: 3.7.1 GEOS version: 3.12.0-CAPI-1.18.0 PROJ version: Rel. 9.2.1, June 1st, 2023 PDAL version: 2.5.5 (git-version: a7569c) Algorithm started at: 2023-08-01T13:02:29 Algorithm 'Generate XYZ tiles (Directory)' starting… Input parameters: { 'BACKGROUND_COLOR' : QColor(0, 0, 0, 0), 'DPI' : 96, 'EXTENT' : '-11887168.949073933,-11805219.796561170,5035929.347135771,5079289.137810403 [EPSG:4326]', 'HTML_ATTRIBUTION' : '', 'HTML_OSM' : False, 'HTML_TITLE' : '', 'METATILESIZE' : 4, 'OUTPUT_DIRECTORY' : 'TEMPORARY_OUTPUT', 'OUTPUT_HTML' : 'TEMPORARY_OUTPUT', 'QUALITY' : 75, 'TILE_FORMAT' : 0, 'TILE_HEIGHT' : 256, 'TILE_WIDTH' : 256, 'TMS_CONVENTION' : False, 'ZOOM_MAX' : 13, 'ZOOM_MIN' : 8 }

Traceback (most recent call last): File "C:\PROGRA~1/QGIS33~1.1/apps/qgis/./python/plugins\processing\algs\qgis\TilesXYZ.py", line 624, in processAlgorithm self.generate(writer, parameters, context, feedback) File "C:\PROGRA~1/QGIS33~1.1/apps/qgis/./python/plugins\processing\algs\qgis\TilesXYZ.py", line 296, in generate metatiles = get_metatiles(self.wgs_extent, zoom, self.metatilesize) File "C:\PROGRA~1/QGIS33~1.1/apps/qgis/./python/plugins\processing\algs\qgis\TilesXYZ.py", line 123, in get_metatiles right_tile, bottom_tile = deg2num(south_edge, east_edge, zoom) File "C:\PROGRA~1/QGIS33~1.1/apps/qgis/./python/plugins\processing\algs\qgis\TilesXYZ.py", line 71, in deg2num ytile = int((1.0 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2.0 * n) ValueError: math domain error

Execution failed after 0.05 seconds

Loading resulting layers Algorithm 'Generate XYZ tiles (Directory)' finished HTML output has been generated by this algorithm. Open the results dialog to check it.


1 Answer 1


For some reason changing -11887168.949073933,-11805219.796561170,5035929.347135771,5079289.137810403 [EPSG:4326]' to '-118.87,-118.05,50.35,50.79 [EPSG:4326]' has worked as I am able to run the plug-in now and have files. The issue now is the leaflet preview doesnt show the tiles. When selecting come with basemap the basemap shows just fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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