farmingpy.eo API#
Implementation of Sentinel 2 Toolbox Neural Network for predicting biophysical parameters from Sentinel 2 data. |
- class BioPhysS2tbx(product='LAI', resolution=20, stbx_version='3.0')[source]#
Implementation of Sentinel 2 Toolbox Neural Network for predicting biophysical parameters from Sentinel 2 data. Uses weights from s2tbx-biophysical: senbox-org/s2tbx
The model does input and output range validation, but omits convexity checks.
Based on: Weiss, M., Baret, F., Jay, S., 2020. S2ToolBox level 2 products LAI, FAPAR, FCOVER. EMMAH-CAPTE, INRAe Avignon. http://step.esa.int/docs/extra/ATBD_S2ToolBox_V2.0.pdf
- __call__(ds, *args, **kwargs)[source]#
Run the model on dataset.
- Parameters:
xarray.DataArray (ds) – Sentinel 2 data. The format needs to match the data retrieved using twinyields.eo.S2SentinelHub class.
- Returns:
Vegetation index
- Return type:
xarray.DataArray
- __init__(product='LAI', resolution=20, stbx_version='3.0')[source]#
- Parameters:
product (str, optional) – Output product, “LAI”, “FAPAR”, “FCOVER”, “LAI_Cab” or “LAI_cw”. Defaults to “LAI”.
resolution (int, optional) – Model resolution to use 10 or 20. Defaults to 20.
stbx_version (str, optional) – Toolbox version for weights 2.1 or 3.0. Defaults to “3.0”.
- read_planet(img_file, apply_mask=True, confidence=60, clip=None)[source]#
Read planetscope AnalyticMS_SR_8b .tif and apply mask.
- Parameters:
img_file (str) – Image file path.
apply_mask (bool, optional) – Apply udm1 mask and remove points with low mask confidence if True. Defaults to True.
confidence (int, optional) – Mask confidence threshold. Defaults to 60.
clip (GeoDataFrame, optional) – GeoDataFrame used to clip the image.
- Returns:
Planetscope image xarray.DataArray: Mask
- Return type:
xarray.DataArray
- planet_to_S2_dataset(ds)[source]#
Convert PlanetScope 8 band image to fake Sentinel2 dataset to be used with twinyields.eo.BioPhysStbx models.
- Parameters:
ds (xarray.DataArray) – Planet image loaded using read_planet.
- Returns:
Dataset with bands that can be used with twinyields.eo.BioPhysStbx 10m models.
- Return type:
xarray.DataArray