Esri / arcgis-python-api

Documentation and samples for ArcGIS API for Python
https://developers.arcgis.com/python/
Apache License 2.0
1.89k stars 1.1k forks source link

incompatible with existing WMTS layers (including those used in non-Python examples) #2098

Open prusswan opened 1 week ago

prusswan commented 1 week ago

Describe the bug

Could not get WMTSLayer to work with these services:

https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS (from https://developers.arcgis.com/rest/services-reference/enterprise/wmts-map-service/)

https://gibs.earthdata.nasa.gov/wmts/epsg4326/best (from https://nasa-gibs.github.io/gibs-api-docs/access-basics/)

I inspected the Python code that is part of installed arcgis package, and realized that WMTSLayer is assuming that the WMTS service only has one layer and one tilematrixset. This is probably the main reason why those WMTS services are not working.

To Reproduce Steps to reproduce the behavior:

timezone_url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS"
timezone_wmts = WMTSLayer(url=timezone_url)
#timezone_wmts = get_local_wmts(timezone_url)

m4 = gis.map()
m4.add_layer(timezone_wmts)
m4
gibs_url = "https://gibs.earthdata.nasa.gov/wmts/epsg4326/best"
#gibs_url = "https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/wmts.cgi?"
#gibs_url = "https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/wmts.cgi?SERVICE=WMTS&request=GetCapabilities"

gibs_wmts = WMTSLayer(url=gibs_url)

m3 = gis.map()
m3.add_layer(gibs_wmts)
m3

error:

<copy the full error message here>

Screenshots N/A

Expected behavior Python SDK should work with existing WMTS services, and display informative errors if there are truly issues with the WMTS services

Platform (please complete the following information):

nanaeaubry commented 1 week ago

@prusswan

We made some updates with WMTSLayer at version 2.4.0. Can you update your version and see if this has been resolved?

nanaeaubry commented 1 week ago

@prusswan When using version 2.4.0 this is how the WMTS Timezone layer looks on the map:

image

Also for the other WMTS when attempting to add to the Map Viewer it makes you choose one layer: image

prusswan commented 1 week ago

@nanaeaubry thanks for the fast turnaround, mainly we are trying to fix/troubleshoot this for ArcGIS Pro and 2.4 will not be readily available (and will also require Python 3.10 and above). Also, as kernel errors are not well propagated to the user interface (when accessed from Pro), hopefully the API can display a simple error/informative message in case the "Add Layer" pop up fails.

It would be best to follow the JS api (https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html) as much as possible since developers would be more familiar with that.

nanaeaubry commented 1 week ago

@prusswan Sure we are now following the JS API a lot more at 2.4.0 since we introduced a new mapping package: arcgis-mapping This uses the webmap spec to create maps and to deal with layers, popups, etc. We are more than welcome to take user feedback for this new package as well.

Unfortunately we do not backport fixes so the only way to benefit from this is to upgrade. I understand this can take some time to get there so I will leave the issue open and if you are able to try this at a later version and have requests we can continue with them here.

As far as a popup for the map, we can look into it but we are focused on automation and not re-creating the map viewer within a notebook. So we can look at other ways to accomplish this or having better documentation for users to understand what they are creating with the WMTSLayer class