hyriver / pygeohydro

A part of HyRiver software stack for accessing hydrology data through web services
https://docs.hyriver.io
Other
68 stars 23 forks source link

Parsing Error When Delineating Watershed's Land Cover #122

Closed mnpmcl closed 1 month ago

mnpmcl commented 2 months ago

What happened?

I'm running into an error when attempting to delineate land cover by geometry, code log output, and environment information attached. Any help would be greatly appreciated!

What did you expect to happen?

No response

Minimal Complete Verifiable Example

import pygeohydro as gh
from pynhd import NLDI

station_ids = ["01031450"]
geometry = NLDI().get_basins(station_ids)
geometry.index = station_ids
desc = gh.nlcd_bygeom(geometry)

MVCE confirmation

Relevant log output

Traceback (most recent call last):

  File ~\AppData\Local\anaconda3\envs\mlreservoir\lib\xml\etree\ElementTree.py:1718 in feed
    self.parser.Parse(data, False)

ExpatError: syntax error: line 1, column 49

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File ~\AppData\Local\anaconda3\envs\mlreservoir\lib\site-packages\IPython\core\interactiveshell.py:3577 in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  Cell In[3], line 13
    desc = gh.nlcd_bygeom(geometry)

  File ~\AppData\Local\anaconda3\envs\mlreservoir\lib\site-packages\pygeohydro\nlcd.py:228 in nlcd_bygeom
    nlcd_wms = NLCD(years=years, region=region, crs=crs, ssl=ssl)

  File ~\AppData\Local\anaconda3\envs\mlreservoir\lib\site-packages\pygeohydro\nlcd.py:85 in __init__
    self.valid_crs = ogc_utils.valid_wms_crs(ServiceURL().wms.mrlc)

  File ~\AppData\Local\anaconda3\envs\mlreservoir\lib\site-packages\pygeoogc\utils.py:856 in valid_wms_crs
    root = ETree.fromstring(ar.retrieve_text([url], [kwds], ssl=False)[0])

  File ~\AppData\Local\anaconda3\envs\mlreservoir\lib\site-packages\defusedxml\common.py:126 in fromstring
    parser.feed(text)

  File ~\AppData\Local\anaconda3\envs\mlreservoir\lib\xml\etree\ElementTree.py:1720 in feed
    self._raiseerror(v)

  File ~\AppData\Local\anaconda3\envs\mlreservoir\lib\xml\etree\ElementTree.py:1627 in _raiseerror
    raise err

  File <string>
ParseError: syntax error: line 1, column 49

Anything else we need to know?

No response

Environment

SYS INFO -------- commit: None python: 3.10.14 | packaged by Anaconda, Inc. | (main, May 6 2024, 19:44:50) [MSC v.1916 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 186 Stepping 2, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: ('English_United States', '1252') PACKAGE VERSION ------------------------------- async-retriever 0.16.1 pygeoogc 0.16.3 pygeoutils 0.16.3 py3dep 0.17.0 pynhd 0.16.3 pygridmet N/A pydaymet N/A hydrosignatures 0.16.0 pynldas2 N/A pygeohydro 0.16.5 aiohttp 3.9.5 aiohttp-client-cache 0.11.1 aiosqlite 0.20.0 cytoolz 0.12.2 ujson 5.10.0 defusedxml 0.7.1 joblib 1.4.2 multidict 6.0.4 owslib 0.31.0 pyproj 3.6.1 requests 2.31.0 requests-cache 1.2.1 shapely 2.0.5 url-normalize 1.4.3 urllib3 2.2.2 yarl 1.9.3 geopandas 1.0.1 netcdf4 1.6.0 numpy 1.26.4 rasterio 1.3.10 rioxarray 0.17.0 scipy 1.13.1 xarray 2023.6.0 click 8.1.7 pyflwdir N/A networkx 3.2.1 pyarrow 14.0.2 folium 0.17.0 h5netcdf 1.3.0 matplotlib 3.8.4 pandas 2.1.4 numba 0.59.1 bottleneck 1.3.7 py7zr N/A pyogrio 0.9.0 -------------------------------
cheginit commented 2 months ago

Thanks for reporting the issue. The issue is with the MRLC web service being down. I will change the error message to avoid future confusion. Please leave this issue open until the MRLC service is back up again.

colby-thrash commented 2 months ago

I was coming to report this issue as well. Glad you are already on top of it. It's unfortunate it has been down for 5 or more days now.

cheginit commented 2 months ago

@colby-thrash I reached out to the MRLC web service maintainers, I will give an update once I hear from them.

cheginit commented 2 months ago

They told me that there's an IT issue with their GeoServer, and they're working on it. They didn't give an ETA, though. So hopefully it won't be long.

cheginit commented 1 month ago

The issue has been solved. There were some breaking changes on the MRLC web service side, so I updated PyGeoHydro to reflect those changes. As a result of these breaking changes on the server side, older versions of PyGeoHydro (before the unreleased 0.17.1) will not work anymore, unfortunately. I will release v0.17.1 tomorrow that includes a fix for the nlcd module, among other things.

cheginit commented 1 month ago

Just released PyGeoHydro v0.17.1. Please test it out and re-open if you still have the same issue.