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

? on landcover.py : categorical transform? #10

Open
wtrainor opened this issue May 4, 2021 · 1 comment
Open

? on landcover.py : categorical transform? #10

wtrainor opened this issue May 4, 2021 · 1 comment

Comments

@wtrainor
Copy link
Collaborator

wtrainor commented May 4, 2021

Hi Lucas,

I'm back at it again. I'm trying to re-use your landcover.py for my hydrocarbon classes. But I keep getting an error here on line 188.

Y[ii,np.isin(arrs['LC'][OFFSET:self.patch_size+OFFSET, OFFSET:self.patch_size+OFFSET],vv)] = 1
IndexError: too many indices for array: array is 3-dimensional, but 4 were indexed

On line 186, Y is created as a 3d matrix (7x128x128) but then I'm not sure what line 188 is trying to do ...

@Lkruitwagen
Copy link
Owner

Hi @wtrainor sorry for the delay! Yes, so, those landcover classes are from Copernicus CORINE. arrs['LC'] is a 2D HxW array with integer values for the different land cover classes. But those landcover classes are heirachically nested, so you can specify an aggregation level lc_agg if you want root, first, or full heirarchy. Then line 188 is annotating the target 3D CxWxH array by looping through each class C and making Y=1 where arrs['LC'] is in C or any of its children in the landcover heirarchy.

What shape is arrs['LC']? Perhaps it's 3D and so np.isin(arrs['LC'][OFFSET:self.patch_size+OFFSET, OFFSET:self.patch_size+OFFSET],vv) is 3D and then Y[...] is being 4D indexed (but is only initialised as 3D)?

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

2 participants