1

I am trying to create a small application that will show zoomed in maps. If possible, I would like to avoid using map tiles.

Going off the example on this page: https://scitools.org.uk/cartopy/docs/v0.15/matplotlib/intro.html

import cartopy.crs as ccrs
import matplotlib.pyplot as plt

ax = plt.axes(projection=ccrs.Mollweide())
ax.stock_img()
ax.set_extent([35,45,35,45])

plt.show()

result: enter image description here

I realize that this is the nature of a bitmap image.

I am just wondering if there is some method I don't know about for showing it in a higher resolution/dpi?

And if not, is there any middle to solution between this and using, say, Open Streetmap tiles?

I think that in order to use a tiled map I would need to run my own server, but I will largely be showing the same few map sections repeatedly, so I would think there must be some way around this.

1

It looks like cartopy package a downsampled version of the Natural Earth 'shaded relief and water' image as the stock image. You could try the original version (available here) and use ax.imshow to load it (following the source for ax.stock_img quite closely).

import os

import cartopy.crs as ccrs
import matplotlib.pyplot as plt

from matplotlib.image import imread


ax = plt.axes(projection=ccrs.Mollweide())

source_proj = ccrs.PlateCarree()
fname = os.path.join('path_to_natural_earth', 'NE1_50M_SR_W.tif')
ax.imshow(imread(fname), origin='upper', transform=source_proj, 
          extent=[-180, 180, -90, 90])

ax.set_extent([35,45,36,46])

plt.show()

Unfortunately this only gives a little improvement (see below), depending the size of your area of interest.

with extent [35,45,35,45]: quick test

with extent [35,45,36,46]: enter image description here

Beyond this, I'd either use vector data for background (Natural Earth have political, physical and cultural vector data), look for a bigger tif, or go with the tiled approach. Stamen terrain might be suitable, as in this cartopy example. Hope that's helpful!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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