-
Notifications
You must be signed in to change notification settings - Fork 388
Closed
Description
Description
Cartopy stop working when you try to color some countries, like Austria (AUT), Albania among others in Europe as far as I could see. My maps heve been working fine until couple last update on april.
Code to reproduce
import matplotlib.pyplot as plt
import cartopy
import cartopy.io.shapereader as shpreader
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
def area(ax, iso, clr) :
shp = shpreader.natural_earth(resolution='10m',category='cultural',name='admin_0_countries')
reader = shpreader.Reader(shp)
countries = reader.records()
for n in countries :
if n.attributes['ADM0_A3'] == iso:
ax.add_geometries(n.geometry, ccrs.PlateCarree(),
facecolor=clr, alpha = 1.00, linewidth =0.15, edgecolor = "black",
label=n.attributes['ADM0_A3'])
return ax
iso3 = ['USA','CAN','RUS','GBR','ISL','FRA','ITA','AUT'] # works fine with this codes
#iso3 = ['USA','CAN','RUS','GBR','ISL','FRA','ITA','CHN','AUT'] # error message - due to "AUT" - Austria
def main():
ax = plt.axes(projection=ccrs.Miller())
states_provinces = cfeature.NaturalEarthFeature(
category='cultural',
name='admin_1_states_provinces_lines',
scale='50m',
facecolor='none')
ax.add_feature(cfeature.LAND)
ax.add_feature(cfeature.COASTLINE)
ax.add_feature(states_provinces, edgecolor='gray')
for n in iso3 :
area(ax,n,"red")
plt.show()
if __name__ == '__main__':
main()
Traceback
File "C:\ProgramData\Anaconda3\lib\site-packages\cartopy\mpl\geoaxes.py", line 588, in add_geometries
feature = cartopy.feature.ShapelyFeature(geoms, crs, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\cartopy\feature\__init__.py", line 231, in __init__
self._geoms = tuple(geometries)
TypeError: 'Polygon' object is not iterable
Full environment definition
Operating system
Windows 10
Cartopy version
0.17.0
conda list
4.64.14
pip list
19.1
bjsilver and asyaf
Metadata
Metadata
Assignees
Labels
No labels