Hi @19giovi87, thanks for trying out the new tilemap
feature in PyGMT v0.10.0!
There are a few reasons the background OpenStreetMap image you used isn’t sharp. The main reason is that OpenStreetMap XYZ tiles are served in a Spherical Mercator (EPSG:3857) format, but are reprojected to geographic lon/lat coordinates (OGC:CRS84), so the text labels can appear distorted or not sharp.
Here are a few suggestions that could help:
- Set the
projection
to a higher value, e.g.M6i
to get a 6 inch map. - Use an alternative tile provider from the list at A full look into providers objects - xyzservices 2023.10.1, or a custom one. There may be one that serves tilemaps in EPSG:4326/OGC:CRS84, though they are not common.
- Use native EPSG:3857 coordinates (same as the tilemap) instead of longitude/latitude for the
region
, and setlonlat=False
. Something like this:
# https://epsg.io/transform
X_LIM = [1018573.3407584531, 1041950.4338250406]
Y_LIM = [4940333.233068203, 4969660.375061779]
fig = pygmt.Figure()
fig.tilemap(
region=X_LIM + Y_LIM,
# projection="X10c",
zoom="auto",
source=contextily.providers.OpenStreetMap.Mapnik,
lonlat=False,
frame=True,
)
fig.savefig("map.png")
produces
Of course, you would then need to reproject any data you overlap on the map to EPSG:3857. Will leave it up to you on what projection system is best for your work. Good luck!