carpentries-incubator / geospatial-python

Introduction to Geospatial Raster and Vector Data with Python
https://carpentries-incubator.github.io/geospatial-python/
Other
159 stars 57 forks source link

Feature/ep 8 multiband rasters #27

Closed bmcandr closed 3 years ago

bmcandr commented 3 years ago

Hi @rbavery,

I took a crack at writing Episode 8 - Working with Multi-Band Rasters. I tried to follow the R lesson as much as possible in terms of content, but, naturally, there are some areas where Python behaves a little differently (in particular, see the TODO messages I left in the end of episode challenges). Feel free to push edits to this branch or request changes from me.

rbavery commented 3 years ago

@bmcandr I've addressed the TO-DOs.

TODO: plotting without using where() to mask NoData results in an improperly stretched RGB image. Alternately, the file can be read in using the masked=True keyword argument in answer 1, but that removes _FillValue from the attributes and querying rio.nodata returns nan rather than -9999.0. Sticking with this potentially confusing approach for now...

.where is required because there are so many NoData values in the HARV_Ortho_wNA.tif file, see the updates to that challenge.

TODO: the answer in the R version of this lesson does not align with Python/rioxarray's default behavior. According to the R lesson, the tif file for rgb_stack_HARV lacks a NoData value in the metadata and R subsequently does not set a value when the file is read. In Python, it seems that rioxarray automatically sets this value to -1.7e+308 (the min/max value of a double in C) and subsequently treats it as 0 when plotting (???). Need to find clarity on this...

I don't think the discrepancy with how R handles NoData in these files is an issue, I think it's ok to focus on explaining how Python handles it. And R must set some sort of value for cells where there is NoData? Is it NaN? I haven't tested the R version so I'm not sure.

There is one sticky problem though, I'm not sure why after masking with .where(), robust=True is still required when plotting. I tried to make the challenge as clear as possible and maybe it's best if for now we don't get too stuck on this minor issue. I think this episode is still a great improvement and can be taught. I'll open a github issue for this and hopefully we or someone else can figure it out later. For now, I'm ready to merge once I get your look at my changes to the episode.

bmcandr commented 3 years ago

Thanks @rbavery. The changes look good to me, but I'm getting an error when I try to serve the lesson locally for preview. The error appears related to the remote theme the Carpentries are using so I imagine you might encounter it as well. I opened an issue to let the maintainers know.

Feel free to merge if it looked good on your end!

rbavery commented 3 years ago

Yeah I think there was a build error with the last commit I made fixing a typo, so I think it is an upstream issue. I'll look into the issue you opened tomorrow, thanks!

On Thu, Jan 7, 2021, 9:36 PM Brendan McAndrew notifications@github.com wrote:

Thanks @rbavery https://github.com/rbavery. The changes look good to me, but I'm getting an error when I try to serve the lesson locally for preview. The error appears related to the remote theme the Carpentries are using so I imagine you might encounter it as well. I opened an issue https://github.com/carpentries/carpentries-theme/issues/10 to let the maintainers know.

Feel free to merge if it looked good on your end!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/carpentries-incubator/geospatial-python/pull/27#issuecomment-756558059, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFJ2ICPYWPOF3Z2GAV4BELTSY2KWHANCNFSM4VGMYX7A .