-
Notifications
You must be signed in to change notification settings - Fork 284
Description
#Since a while, I am using the wmts function of cartopy but since last week this function does not works returning this error:
KeyError: 'Content metadata for layer "AMSUA_NOAA15_Brightness_Temp_Channel_10" already exists'
The run code is coming from the cartopy web doc.
below the code:
`
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
def main():
url = 'https://map1c.vis.earthdata.nasa.gov/wmts-geo/wmts.cgi'
layer = 'VIIRS_CityLights_2012'
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
ax.add_wmts(url, layer)
ax.set_extent([-15, 25, 35, 60], crs=ccrs.PlateCarree())
ax.set_title('Suomi NPP Earth at night April/October 2012')
plt.show()
if name == 'main':
main()
`
The issue come from _buildMetadata method into WebMapTileService class. The function called gather_layers raise an KeyError if there are duplicated element... But It should be better to add elements if they are not already in the dictionary called "contents"? And just add a warning for duplicate layers.
Below example to fix this issue:
def gather_layers(parent_elem, parent_metadata): for index, elem in enumerate(parent_elem.findall(_LAYER_TAG)): cm = ContentMetadata( elem, parent=parent_metadata, index=index + 1,parse_remote_metadata=parse_remote_metadata) if cm.id: if not cm.id in self.contents: self.contents[cm.id] = cm else: warnings.war('Content metadata for layer "%s" ' 'already exists' % cm.id) gather_layers(elem, cm)
Thank for help.
Fabien Blarel