GeoscienceAustralia / dea-notebooks

Repository for Digital Earth Australia Jupyter Notebooks: tools and workflows for geospatial analysis with Open Data Cube and Xarray
https://docs.dea.ga.gov.au/notebooks/
Apache License 2.0
442 stars 128 forks source link

"shorelines unknown" in DEA Coastlines notebook #1133

Closed CEKrause closed 1 year ago

CEKrause commented 1 year ago

Describe the bug/issue The DEA Coastlines notebook has a bug in cell 2, line 6. The bug is coming from dea_tools/coastal.py line 207.

Steps to reproduce

  1. Open DEA Sandbox
  2. Launch the "DEA_datasets/DEA_Coastlines.ipynb" notebook
  3. Run all cells
  4. Code in cell 2 produces error:
---------------------------------------------------------------------------
ServiceException                          Traceback (most recent call last)
Cell In[2], line 6
      3 ymin, xmax = -33.66, 115.30
      5 # Load DEA Coastlines annual shorelines data 
----> 6 deacl_shorelines_gdf = get_coastlines(bbox=(xmin, ymin, xmax, ymax), 
      7                                       layer='shorelines')
      9 # Print example output
     10 deacl_shorelines_gdf.head()

File ~/DEA_datasets/../Tools/dea_tools/coastal.py:207, in get_coastlines(bbox, crs, layer, drop_wms)
    205 wfs = WebFeatureService(url=WFS_ADDRESS, version="1.1.0")
    206 layer_name = f"dea:{layer}"
--> 207 response = wfs.getfeature(
    208     typename=layer_name,
    209     bbox=tuple(bbox) + (crs,),
    210     outputFormat="json",
    211 )
    213 # Load data as a geopandas.GeoDataFrame
    214 coastlines_gdf = gpd.read_file(response)

File /env/lib/python3.8/site-packages/owslib/feature/wfs110.py:348, in WebFeatureService_1_1_0.getfeature(self, typename, filter, bbox, featureid, featureversion, propertyname, maxfeatures, srsname, outputFormat, method, startindex, sortby)
    333 elif method.lower() == "post":
    334     base_url, data = self.getPOSTGetFeatureRequest(
    335         typename=typename,
    336         filter=filter,
   (...)
    345         sortby=sortby,
    346     )
--> 348 u = openURL(base_url, data, method, timeout=self.timeout,
    349             headers=self.headers, auth=self.auth)
    351 # check for service exceptions, rewrap, and return
    352 # We're going to assume that anything with a content-length > 32k
    353 # is data. We'll check anything smaller.
    354 if "Content-Length" in u.info():

File /env/lib/python3.8/site-packages/owslib/util.py:236, in openURL(url_base, data, method, cookies, username, password, timeout, headers, verify, cert, auth)
    233         serviceException = se_tree.find(possible_error)
    234         if serviceException is not None:
    235             # and we need to deal with some message nesting
--> 236             raise ServiceException('\n'.join([t.strip() for t in serviceException.itertext() if t.strip()]))
    238 return ResponseWrapper(req)

ServiceException: Feature type dea:shorelines unknown

Environment information DEA Sandbox default environment.

robbibt commented 1 year ago

Hey @CEKrause, we did change that name in the WFS in a recent release, but I think the notebook should be updated to the latest version, e.g. https://docs.dea.ga.gov.au/notebooks/DEA_products/DEA_Coastlines.html#Annual-shorelines image

Can you check if your notebook is fully up to date?

CEKrause commented 1 year ago

@robbibt This is just the default notebook that's loaded in the Sandbox. I thought that should auto pull the latest image? I restarted everything and it's still not updating properly and is using the old layer name.

CEKrause commented 1 year ago

Mystery solved!

I was running the DEA Coastlines datasets from a legacy folder in the DEA Sandbox: DEA_datasets/DEA_Coastlines.ipynb. This is an old folder that is no longer maintained, but that hasn't been deleted in case anyone was storing personal notebooks in this system folder.

The maintained and correctly working DEA Coastlines notebook is DEA_products/DEA_Coastlines.ipynb.