Reputation: 633
I am trying to plot maps using Cartopy offline. I've found this post:
Location of stored offline data for cartopy
However, after changing cartopy.config['data_dir']
to 'C:/...'
where the downloaded files are located, when I try to draw coastlines, it still wants to download the map.
cartopy.config['data_dir'] = '.../CartopyMaps'
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()
The console says :
Downloading:
http://naciscdn.org/naturalearth/110m/physical/ne_110m_coastline.zip
However, I have ne_110m_coastline
dbf, shp, and shx files in .../CartopyMaps/shapefiles/natural_earth/physical/
Why does Cartopy not see my local maps and how can I help it?
Upvotes: 4
Views: 4079
Reputation: 537
I shared a step by step solution here: https://discourse.holoviz.org/t/using-geoviews-tile-sources-offline/4859/5
TLDR:
import cartopy
import geoviews as gv
from bokeh.resources import INLINE
cartopy.config["pre_existing_data_dir"] = "/Users/ahuang/.cartopy/cartopy"
print(cartopy.config)
gv.extension("bokeh")
coastline = gv.feature.coastline()
borders = gv.feature.borders()
world = (coastline * borders).opts(global_extent=True)
gv.save(world, "world.html", resources=INLINE)
Upvotes: 0
Reputation: 1
i had the similar problem and was confused for quite a while. after i downloaded the whole offline dataset and put them in the right dir, after runing the code
...
states = NaturalEarthFeature(category="cultural", scale="50m",
facecolor="none",
name="admin_1_states_provinces_shp")
...
the console still says:
Downloading:
...50m/cultural/ne_50m_admin_1_states_provinces_lines_shp.zip
however, i found there is a slight difference between the file ne_50m_admin_1_states_provinces_lines.shp
i downloaded and the file ne_50m_admin_1_states_provinces_lines_shp.zip
cartopy tries to acquire ('_shp').
therefore i changed the command into this and it worked:
states = NaturalEarthFeature(category="cultural", scale="50m",
facecolor="none",
name="admin_1_states_provinces")
Upvotes: 0
Reputation: 85
Try using the "pre_existing_data_dir" path instead of the "data_dir".
from os.path import expanduser
import cartopy
cartopy.config['pre_existing_data_dir'] = expanduser('~/cartopy-data/')
Upvotes: 0