[Qgis-user] Fwd: GDAL2tiles in local crs in QGIS

Even Rouault even.rouault at spatialys.com
Thu Jan 14 07:21:21 PST 2021


On jeudi 14 janvier 2021 10:07:02 CET Marco Bernasocchi wrote:
> Hi all,
> just a short/probably stupid question that I'm loosing way too much time on
> already :)
> 
> is there a way to have gdal2tiles create tiles in a local crs (for example
> EPSG:2056) and load them into QGIS?
> I'm doing
> gdal2tiles.py --profile=raster --zoom=0-5 --s_srs=EPSG:2056
> CH_over_2000_lv95.tif test_tiles
> 
> and it looks like the resulting tilemapresource.xml and the openlayers
> example are correct, but loading them in QGIS using
> 
> file:///home/marco/gis/test_tiles/{z}/{x}/{y}.png
> 
> I get a wrong placement (crs of the tiles is set to 3857, which is
> "workaroundable") and wrong tiles alignment (looks like 0,0 top left vs 0,0
> bottom left).
> 
> I know the TMS "standard" is old but it would still be nice to be able to
> quickly take a tiff, chop it up in tiles and use it in QGIS. And using
> --xyz parameter results in correct tiles but in 3857
> 
> Am I doing something stupidly wrong :) ? or is WMTS really the only way to
> have tiles in local crs?

I believe --s_srs=EPSG:2056 will be ignored in --profile=raster mode. It is 
only used for reprojecting to the SRS implied by other profiles.

In --profile=raster mode, the (0,0) tiles is the origin of your raster. Is 
that what you want ? Or do you want some tiling scheme based on EPSG:2056 
where the origin of the tiling scheme is some point generally far from your 
raster origin ? If the later, you should create a tms_XXXXX.json file and 
place it in GDAL data directory (see the existing profiles such as 
tms_MapML_APSTILE.json). Then gdal2tiles (GDAL >= 3.2) will be able to use it.

But re-reading your email, the issue might be more assumptions on QGIS side 
regarding the CRS (EPSG:3857) and the tile origin

Even


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the Qgis-user mailing list