arthur-e / unmixing

Interactive tools for spectral mixture analysis of multispectral raster data in Python
MIT License
104 stars 24 forks source link

Classification with GIS data on endmember locations #11

Open sebamed96 opened 2 years ago

sebamed96 commented 2 years ago

I am wondering is it possible to implement soil classification with SASMA, where the classification parameters are parcels in .SHP/.GeoJSON format?

arthur-e commented 2 years ago

Hi @sebamed96, could you describe in more detail what you mean by "classification parameters"? Are these the locations of known spectrally invariant targets/ pseudo-invariant features? Or are they spectra?

The SASMA example in this library assumes that you want to find new spectral endmembers within a moving window. If you already have spectral endmembers (e.g., from a spectral library) in mind, SASMA is probably not what you want to use. Alternatively, if your spectral endmembers are well-distributed throughout the spatial domain of interest, you could design your moving window so that it is large enough to ensure potential endmembers are always contained within. See circa code block [4] in the above example.

sebamed96 commented 2 years ago

Hello and thank you for your fast response!

Well, i was hoping to use some SMA method for land/soil classification based on data that i have; few parcels with know crop on them (corn, sunflower, etc..). The idea is to use Sentinel 2 data ( and maybe later integration with Sentinel 1), 1 image for every month of the year, and compare the classification accuracy.

arthur-e commented 2 years ago

@sebamed96, that's great! I would try vanilla LSMA (i.e., not spatially adaptive) first. Check out the iPython Notebooks I provided in the docs folder.

Specifically, the section "Endmember selection" describes how to select endmembers from the mixing space. You might already have endmembers in mind because you have a "few parcels with know[n] crop" types (i.e., training data). In that case, you just need to extract the spectra at those coordinates. You could do that easily with the tools in this library or, if you want to get the mean spectra over a region (e.g., entire parcel), you could use zonal statistics in a GIS program. Either way, once you have your endmembers defined as an array, you're ready to start.

Be aware that your different crop types might not span the mixture space. You'll likely need to choose endmember(s) for soil and substrate, possibly "bright soil" and "dark soil" or "soil" and "impervious surface." You can also use this library to explore the mixing space. When you call FeatureSpace.plot_feature_space() with interact=True, you can draw a rectangular bounding box in the mixing space with two clicks inside the plot window (i.e., top-left and bottom-right corners OR bottom-left and top-right corners). This will generate a KML file in your working directory with the coordinates of pixels that fall in that box. Drawing the box around a corner of the mixing space will help you identify potential end-members.

This is research code so drawing the bounding box is pretty clunky and SLOW. It may be several seconds after your second click before you see the box drawn in the plot window. I would love to improve the drawing performance someday! Drawing performance should be roughly proportional to the complexity of the plot, i.e., the number of pixels used to the draw the FeatureSpace.