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

Issue with primitives module #14

Open
apuzzi opened this issue Nov 3, 2023 · 3 comments
Open

Issue with primitives module #14

apuzzi opened this issue Nov 3, 2023 · 3 comments

Comments

@apuzzi
Copy link

apuzzi commented Nov 3, 2023

I'm getting errors using the Colab notebook example for generating the primitives. Here is the notebook: https://colab.research.google.com/drive/1vr6eZkHfIvHTNKwgStIOdIqK1Q3av28Y?usp=sharing

@kyle-woodward
Copy link
Member

This was propagating from gettop20() helper function in Primitives - you had less than 20 input band features passed to the RF models and we hadn't accounted for that case.

Solution: if total input features <= 20, keep all features in the model, otherwise take top 20 most important features.

Closed with PR #15

@apuzzi
Copy link
Author

apuzzi commented Nov 8, 2023

Thank you! I believe I get another error that refers to my particular case. So in the same notebook, (https://colab.research.google.com/drive/1vr6eZkHfIvHTNKwgStIOdIqK1Q3av28Y?usp=sharing) when trying to export the primitives as an IC asset I get an error that I believe comes the variable desc in export_to_asset (https://github.com/sig-gis/rlcms/blob/main/src/rlcms/primitives.py#L215). desc in my case results in floats (or strings with ".", not sure) such as 1.0, 2.0 , 3.0, etc (from maybe the sampling notebook, the LC class numbers). Once these numbers/strings get appended to the asset ID, it results in the error Name "projects/pc300-samz-imbabura/assets/imagery/primitives_v1/Primitive2.0" is invalid. Each segment must contain only the following characters: a..z, A..Z, 0..9, "_" or "-". Each segment must be at least 1 character long and at most 100 characters long.
I partially solved this by slicing desc in the notebook: desc = f"Primitive{ee.Image(prim).getString('Primitive').slice(0,1).getInfo()}". The "partially" is because since I have a class # 10, I get two primitive images called "Primitive1". For a robust fix though, I think some check needs to exist before so in the case you get floats or unallowed characters you convert them to integers or replace "." for "_" or something like that.

@kyle-woodward kyle-woodward reopened this Nov 8, 2023
@kyle-woodward
Copy link
Member

Agree to the problem. I think the sustainable solution is to put this check into format_pts() https://github.com/sig-gis/rlcms/blob/main/src/rlcms/primitives.py#L14

This is where the training pts are converted into each set of primitive points. Putting the check here should keep us from having to do the checks in more functions that we develop later. We can just map a .get().set() across entire training FC, converting floating point numbers to integers before beginning the regular primitive property formatting.

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