See image, particularly with the text. Why would this be happening?
-
7Because it is being transformed in the map canvas to your project CRS of EPSG:3347. For visualising the xyz layer in it's native crs, set your project to EPSG:3857 and let QGIS transform your vector layer in the map canvas. Just don't rely on EPSG:3857 for any distance or area measurements.– Ben WCommented Jan 17, 2023 at 2:27
-
@BenW your comment looks like a good answer (hint hint :)– user2856Commented Jan 17, 2023 at 3:07
1 Answer
You can also achieve good image quality with your local CRS if you use a little trick with GDAL.
- Create a WMS description file for your TMS layer (i.e. google.xml). You can choose the max. Tilelevel here (i.e. 10):
<GDAL_WMS>
<Service name='TMS'>
<ServerUrl>https://maps.googleapis.com/maps/vt?pb=!1m5!1m4!1i${z}!2i${x}!3i${y}!4i256!2m3!1e0!2sm!3i664404949!3m17!2sde!3sUS!5e18!12m4!1e68!2m2!1sset!2sRoadmap!12m3!1e37!2m1!1ssmartmaps!12m4!1e26!2m2!1sstyles!2zcy50OjF8cC52Om9ufHAubDozMyxzLnQ6NXxwLmM6I2YyZTVkNCxzLnQ6NDB8cy5lOmd8cC5jOiNjNWRhYzYscy50OjQwfHMuZTpsfHAudjpvbnxwLmw6MjAscy50OjN8cC5sOjIwLHMudDo0OXxzLmU6Z3xwLmM6I2M1YzZjNixzLnQ6NTB8cy5lOmd8cC5jOiNlNGQ3YzYscy50OjUxfHMuZTpnfHAuYzojZmJmYWY3LHMudDo2fHAudjpvbnxwLmM6I2FjYmNjOQ!4e0</ServerUrl>
</Service>
<Transparent>FALSE</Transparent>
<DataWindow>
<UpperLeftX>-20037508.34</UpperLeftX>
<UpperLeftY>20037508.34</UpperLeftY>
<LowerRightX>20037508.34</LowerRightX>
<LowerRightY>-20037508.34</LowerRightY>
<TileLevel>10</TileLevel>
<TileCountX>1</TileCountX>
<TileCountY>1</TileCountY>
<YOrigin>top</YOrigin>
</DataWindow>
<Projection>EPSG:3857</Projection>
<BlockSizeX>256</BlockSizeX>
<BlockSizeY>256</BlockSizeY>
<BandsCount>3</BandsCount>
<UnsafeSSL>true</UnsafeSSL>
<MaxConnections>5</MaxConnections>
<Cache />
</GDAL_WMS>
- Run
gdalwarp
(i.e. in OSGeo4W shell) to transform the TMS Datasource into a virtual raster (VRT) file with your project CRS (EPSG:3347). I use a bounding box to speed up processing (-te switch):
gdalwarp -r cubic -of VRT -t_srs EPSG:3347 -te 7133426 893133 7283099 983227 google.xml google3347.vrt
- Drag & Drop the VRT into QGIS
If you like to store the VRT datasource directly in QGIS, you need to edit the google3347.vrt file.
Exchange the following line:
<SourceDataset relativeToVRT="1">google.xml</SourceDataset>
with the content of osm.xml (replace <
and >
with <
and >
):
<SourceDataset relativeToVRT="0"><GDAL_WMS><Service name='TMS'><ServerUrl>https://maps.googleapis.com/maps/vt?pb=!1m5!1m4!1i${z}!2i${x}!3i${y}!4i256!2m3!1e0!2sm!3i664404949!3m17!2sde!3sUS!5e18!12m4!1e68!2m2!1sset!2sRoadmap!12m3!1e37!2m1!1ssmartmaps!12m4!1e26!2m2!1sstyles!2zcy50OjF8cC52Om9ufHAubDozMyxzLnQ6NXxwLmM6I2YyZTVkNCxzLnQ6NDB8cy5lOmd8cC5jOiNjNWRhYzYscy50OjQwfHMuZTpsfHAudjpvbnxwLmw6MjAscy50OjN8cC5sOjIwLHMudDo0OXxzLmU6Z3xwLmM6I2M1YzZjNixzLnQ6NTB8cy5lOmd8cC5jOiNlNGQ3YzYscy50OjUxfHMuZTpnfHAuYzojZmJmYWY3LHMudDo2fHAudjpvbnxwLmM6I2FjYmNjOQ!4e0</ServerUrl></Service><Transparent>FALSE</Transparent><DataWindow><UpperLeftX>-20037508.34</UpperLeftX><UpperLeftY>20037508.34</UpperLeftY><LowerRightX>20037508.34</LowerRightX><LowerRightY>-20037508.34</LowerRightY><TileLevel>10</TileLevel><TileCountX>1</TileCountX><TileCountY>1</TileCountY><YOrigin>top</YOrigin></DataWindow><Projection>EPSG:3857</Projection><BlockSizeX>256</BlockSizeX><BlockSizeY>256</BlockSizeY><BandsCount>3</BandsCount><UnsafeSSL>true</UnsafeSSL><MaxConnections>5</MaxConnections><Cache /></GDAL_WMS></SourceDataset>
and copy the content of google3347.vrt into your data source URI using the ChangeDataSource
plugin: