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

🚸 Walkthrough on stacking time-series earth observation data #62

Merged
merged 12 commits into from
Sep 26, 2022

Conversation

weiji14
Copy link
Owner

@weiji14 weiji14 commented Sep 20, 2022

Tutorial on stacking a time-series of Synthetic Aperture Radar polarization channels + Copernicus DEM for a change detection task. Will be looking at landslides digitized by UNOSAT over Gunung Talamau, Indonesia after the 25 Feb 2022 Pasaman Barat earthquake.

Preview at https://zen3geo--62.org.readthedocs.build/en/62/stacking.html

Satellite detected landslide extents as of 4 March 2022 over Gunung Talamau, Indonesia

TODO:

  • Show how to do pystac-client spatiotemporal query and stack STAC items using stackstac
  • Add Copernicus DEM into the DataPipe
  • Add landslide segmentation masks (rasterized from vector)
  • Compile everything together and pass into a DataLoader

Part of #48. Xref microsoft/torchgeo#412 (comment).

Initial draft tutorial on stacking a time-series of Synthetic Aperture Radar polarization channels for a change detection task. Will be looking at landslides digitized by UNOSAT over Gunung Talamau, Indonesia after the 25 Feb 2022 Pasaman Barat earthquake. Also added pystac-client and stackstac to the docs extras.
@weiji14 weiji14 added the documentation Improvements or additions to documentation label Sep 20, 2022
@weiji14 weiji14 added this to the 0.5.0 milestone Sep 20, 2022
@weiji14 weiji14 self-assigned this Sep 20, 2022
Show how to get the Copernicus Digital Elevation Model from a STAC catalog. Added some more subsections to the first part, included a teaser thumbnail for both Sentinel-1 GRD and Copernicus DEM over the study area. Wrote some clarification text on what parameters go where when the STAC API query is made, that may or may not be helpful.
Forgot to rename the `dp_stac_items` variable to `dp_sen1_items` in f76a9b7. Also completed the alt-text for the Copernicus DEM thumbnail.
Show how to get the vector layer loaded as a geopandas.GeoDataFrame and added an overview of the layer stacking steps. Reduced the size of the Sentinel-1 xarray.DataArray by clipping to just Gunung Talamau, reducing the spatial resolution from 10m to 30m, and optimizing dtype from float64 to float16. Also added link to Humanitarian Data Exchange where the nice link to the shapefile (on a server that supports HTTP range requests) can be found.
Show how to create a SAR datacube with the Copernicus DEM layer appended. Specifically, the datacube is an xarray.Dataset with data variables VH, VV and DEM. Realized that a `stackstac.mosaic` DataPipe will be needed, but here's doing the mosaic in the collate function for now.
Show how to turn a stack of DEM tiles in an xarray.DataArray into a mosaic using StackSTACMosaicker, rather than doing it in the collate function. Also renamed some DataPipes to have an 'er' after #64.
Show how to perform rasterization of the vector polygons (following previous vector-segmentation-mask tutorial) and add the resulting mask as another data variable layer of the xarray.Dataset datacube. Thinking about creating a general purpose xarray collate function that does data variable appending since this is the third time it's been needed.
Switching to the Radiometrically Terrain Corrected (RTC) intensity dataset because it's georeferenced and actually better over steep topography at Gunung Talamau. However, this requires setting a PC_SDK_SUBSCRIPTION_KEY (finally found the correct one) and 🤞 that it works on readthedocs! Also did some minor edits to the Copernicus DEM mosaic section.
Realized that the horizontal striped mask was not an issue with datashader but on the xarray merge. Need to use `join="override"` instead of `join="outer"`. With that, all four layers (vh, vv, dem, mask) can be visualized nicely. Subplot code is a little messy, but well, see https://stackoverflow.com/questions/70667835/use-different-color-scales-in-xarray-faceted-imshow.
Completing the stacking layer tutorial in one go! Hastily adapted some FDL2022 code for creating pre-event, post-event and target label tensors, and turned them into tensors without any proper averaging or transposing of the dimensions. Credited the FDL2022 SAR Change Detection challenge and linked to the final showcase Youtube video. Hopefully can do InSAR and NISAR some day!
@weiji14 weiji14 marked this pull request as ready for review September 26, 2022 03:10
@weiji14 weiji14 merged commit 01a8983 into main Sep 26, 2022
@weiji14 weiji14 deleted the stacking branch September 26, 2022 03:21
weiji14 added a commit that referenced this pull request Oct 2, 2022
Refactoring the xarray collate functions to use `xr.merge` instead of the dictionary style way of appending data variables to an xarray.Dataset. Solution adapted from 7787f8e in #62 that is more robust to images being cut off due to rounding issues as with 6b18934 in #31. Downside is the need to verbosely rename the xarray.DataArray objects, and handle some conflicting coordinate labels.
weiji14 added a commit that referenced this pull request Oct 2, 2022
* ♻️ Use xarray.merge with join="override" in collate functions

Refactoring the xarray collate functions to use `xr.merge` instead of the dictionary style way of appending data variables to an xarray.Dataset. Solution adapted from 7787f8e in #62 that is more robust to images being cut off due to rounding issues as with 6b18934 in #31. Downside is the need to verbosely rename the xarray.DataArray objects, and handle some conflicting coordinate labels.

* 📝 Minor tweaks to vector segmentation mask walkthrough

A few whitespace fixes and fixing some DataPipe references.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant