Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEM not array like in example scripts #360

Closed
LeaHartl opened this issue Apr 23, 2023 · 10 comments
Closed

DEM not array like in example scripts #360

LeaHartl opened this issue Apr 23, 2023 · 10 comments

Comments

@LeaHartl
Copy link

Hello, I am having issues running some of the example scripts and getting error messages related to "DEM" objects not being array like. The problems go away if I change the scripts to use DEM.data rather than DEM. For example, in plot_standardization.py line 41 throws an error ('DEM' object is not subscriptable) as:
dh_arr = dh[~mask_glacier].filled(np.nan)
but works like this:
dh_arr = dh.data[~mask_glacier].filled(np.nan)
Similarly, plot_nuth_kaab.py complains in line 39 (ValueError: Both DEMs need to be array-like (implement a numpy array interface)) with:
nuth_kaab.fit(reference_dem, dem_to_be_aligned, inlier_mask)
but this works:
nuth_kaab.fit(reference_dem.data, dem_to_be_aligned.data, inlier_mask, transform=reference_dem.transform)
There are also some more 'DEM' object is not subscriptable errors in plot_nuth_kaab.py
Is this some kind of version problem on my end, or has the DEM class been changed?

@rhugonnet
Copy link
Member

Hi @LeaHartl,

This is due to recent changes in GeoUtils, which have been fixed in xDEM: #341.

The reason it does not work for you:
Our documentation is pulled from latest (i.e., the GitHub repository) and not the last released version (what you probably installed). If you clone the GitHub repository (installation for developers), everything will work.

I'll open an issue for us to start creating different branches for the documentation, so that latest does not become public until a release is made. We had this in mind for after the first stable release v0.1 (which we'll hopefully manage to push out this year), right now a lot of stuff is still very much in development.

@rhugonnet
Copy link
Member

Issue moved to #361.
We will also make a new release soon (couple days), so that you can just install the new version of xDEM through conda, and for the documentation to be up-to-date with the package.

@rhugonnet
Copy link
Member

@LeaHartl: new releases of xDEM (0.0.8) and GeoUtils (0.0.11) are out, available directly through conda-forge! Everything from the documentation should work nicely after updating those (all scripts and tests pass on Linux/Mac/Windows) 🙂

P.S: are you still at the GI?! (those TV in the entrance make me know people's name without ever having seen them). I'm a guest in WRRB 😉

@LeaHartl
Copy link
Author

@rhugonnet awesome, thank you. I am going to get a lot of usage out of xdem and the documentation is fantastic too. I am still/again employed at the GI but working remotely from europe. my employment situation is a little messy, reminds me of how my raster processing code was before I found xdem ;)

@LeaHartl
Copy link
Author

@rhugonnet I now updated to xdem 0.0.9 and geoutils 0.0.12 and the import statement fails for both xdem and geoutils with "AttributeError: type object 'GeoSeries' has no attribute 'normalize'" Any ideas?

@adehecq
Copy link
Member

adehecq commented Apr 28, 2023

Hi @LeaHartl,
I had the same issue after making the update in geoutils/xdem. I think this is because the method normalize was implemented in a late version of geopandas, version 0.12 to be exact, according to the changelog. Updating your version of geopandas should solve your issue. It did for me at least !

@LeaHartl
Copy link
Author

@adehecq yes that did it, THANK YOU!

@rhugonnet
Copy link
Member

Perfect!

A good rule to know: if the build is passing on the GitHub page (https://github.com/GlacioHack/xdem), there's a 99% chance that the package will work correctly by re-installing the environment from scratch: mamba install -c conda-forge xdem.

The 1% is if a package that we depend on (GeoPandas for example) pushed a release since our build ran its tests, and this release introduces a bug. It is quite rare but it happens, and is generally solved within a couple days by the package.

@rhugonnet
Copy link
Member

Opening an issue to force geopandas > 0.12.0

@LeaHartl
Copy link
Author

fyi, I also had to update shapely from 1.8 to 2.0.x for some of the geoutils functionalities to work after I switched to xdem 0.0.9 and gu 0.0.12. this seems like a "me" problem because I am working in a weird older environment due to some other dependencies, just mentioning it to let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants