Skip to content
Merged
Prev Previous commit
Next Next commit
Fix block location Basemap.arcgisimage for cachedir creation
  • Loading branch information
molinav committed Feb 14, 2024
commit 0131763aa7d71de0c3b189f489228e9b55f767c4
6 changes: 3 additions & 3 deletions packages/basemap/src/mpl_toolkits/basemap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4361,9 +4361,6 @@ def arcgisimage(self, server="http://server.arcgisonline.com/ArcGIS",
# Generate a filename for the cached file.
filename = "%s-bbox-%s-%s-%s-%s-bboxsr%s-imagesr%s-size-%s-%s-dpi%s.png" % \
(service, xmin, ymin, xmax, ymax, self.epsg, self.epsg, xpixels, ypixels, dpi)
# Check if the cache directory exists, if not create it.
if not os.path.exists(cachedir):
os.makedirs(cachedir)
# Return fast if the image is already in the cache.
cache_path = os.path.join(cachedir, filename)
if os.path.isfile(cache_path):
Expand All @@ -4379,6 +4376,9 @@ def arcgisimage(self, server="http://server.arcgisonline.com/ArcGIS",
img = Image.open(conn)
# Save to cache if requested.
if cachedir is not None:
# Check if the cache directory exists, if not create it.
if not os.path.exists(cachedir):
os.makedirs(cachedir)
img.save(cache_path)
return self.imshow(img, ax=ax, origin="upper")

Expand Down