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

Adapt CDL cmap to match ordinal label mapping #1368

Merged
merged 12 commits into from
Jun 2, 2023

Conversation

nilsleh
Copy link
Collaborator

@nilsleh nilsleh commented May 25, 2023

new cmap with ordinal labels:

new_cmap = {}
for key, val in cmap.items():
    if key in ordinal_label_map:
        new_cmap[ordinal_label_map[key]] = val

Also saw that return fig was missing from plot.

Example:
Screenshot from 2023-05-25 16-36-15

@github-actions github-actions bot added the datasets Geospatial or benchmark datasets label May 25, 2023
@adamjstewart
Copy link
Collaborator

Can you upload an example plot?

@adamjstewart adamjstewart added this to In progress in SSL4EO-L via automation May 25, 2023
@adamjstewart adamjstewart added this to the 0.4.2 milestone May 25, 2023
@adamjstewart
Copy link
Collaborator

adamjstewart commented May 26, 2023

Hmm, the plot looks a little odd. Can you use the geolocation from the sample image and view the raw CDL file in QGIS at the same location? Especially here in the Midwest, almost everything should be corn (yellow) or soybean (green), with a small amount of urban (gray) and more grassland (light green) as you move further west. I'm not even sure what the white class would be.

@nilsleh
Copy link
Collaborator Author

nilsleh commented May 26, 2023

I have never used QGIS, so I tried and the image falls somewhere here. don't know how to exactly align the above image within QGIS, bbox of the above sample is BoundingBox(left=-92.71206128810316, bottom=41.1143125729992, right=-92.61838776978843, top=41.18530100873502):
Screenshot from 2023-05-26 10-19-30

@adamjstewart
Copy link
Collaborator

Yeah, that second plot is what it should look like. What image and mask year is it? I'll zoom in on QGIS until I get the exact plot it should look like.

@adamjstewart
Copy link
Collaborator

If it's 2019, the plot should look something like this:
Screenshot 2023-05-26 at 9 57 47 AM

@nilsleh
Copy link
Collaborator Author

nilsleh commented May 26, 2023

I had 2011

@calebrob6
Copy link
Member

Sup fellas, I think the ax.imshow()s need a vmin=0, vmax=255, and interpolate="none".

Also, would gently recommend not spending time on this :)

@adamjstewart
Copy link
Collaborator

2011 version is a bit more sporadic, closer to what you're seeing:
Screenshot 2023-05-26 at 11 29 05 AM
Looks like corn is being mapped from yellow to white and soybean is being mapped from green to yellow.

@adamjstewart
Copy link
Collaborator

Sup fellas, I think the ax.imshow()s need a vmin=0, vmax=255, and interpolate="none".

You are correct, although vmax should be len(cmap) - 1, not 255.

Also, would gently recommend not spending time on this :)

I needed a break :)

@adamjstewart
Copy link
Collaborator

I plotted SSL4EOLBenchmark, NLCD, and CDL and compared them against the QGIS visualizations and everything looks correct.

ssl4eo_nlcd
nlcd
ssl4eo_cdl
cdl

adamjstewart
adamjstewart previously approved these changes May 27, 2023
Copy link
Collaborator

@adamjstewart adamjstewart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nilsleh see what you think of this solution

@adamjstewart
Copy link
Collaborator

@calebrob6 does Chesapeake not map mask values to ordinal ranges? Should it? Trying to decide whether or not we need cmap to be a dict or if it can be a much simpler list.

@adamjstewart
Copy link
Collaborator

Decided to keep it as a dict to match rasterio.DatasetReader.colormap()

adamjstewart
adamjstewart previously approved these changes May 27, 2023
@adamjstewart
Copy link
Collaborator

I can split the changes to each file into separate PRs if you want. Might make it easier to backport only CDL (the rest will have to wait until 0.5).

@adamjstewart adamjstewart merged commit 0a564dd into microsoft:main Jun 2, 2023
21 checks passed
SSL4EO-L automation moved this from In progress to Done Jun 2, 2023
@adamjstewart adamjstewart modified the milestones: 0.4.2, 0.5.0 Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasets Geospatial or benchmark datasets
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants