Preparing the land cover raster

There is currently no automatic script to generate land cover rasters. This part has to be done manually by the user.

Pixel mode

For the pixel mode, the user has to find a land cover raster and project it on the same grid as the NDVI and weather datasets. Each class should be represented as an integer (starting at one) and saved as a Geotiff file (for OTB). Once you have a valid raster, you can reproject it and clip it using the OTB Superimpose function. Here is an example of the command you can run to do that:

(modspa_pixel) $ otbcli_Superimpose -inr reference_satellite_image.tif -inm lc_raster_input.tif -out lc_raster_output.tif -interpolator nn

Where:

  • -inr is the reference image on which you want to superimpose your raster (e.g. Sentinel-2 image or extraction of Sentinel-2 image).

  • -inm is the raster you want to superimpose.

  • -out is the name of the output raster that will be created

  • -interpolator is the chosen interpolator (nn stands for nearest neighbor), other interpolators will not work as they will create new float values between the integer values.

  • additional parameters like the data type can be found in the OTB documentation

You will then have a land cover raster on the same grid as the other inputs.

Parcel mode

The land cover information has to be included in the parcel definition shapefile. Each parcel should have a land cover class identification number (integers starting by one). Extraction is then done automatically using the custom_inputs_parcel.ipynb. An xarray dataset can then be created with the help of this function:

modspa_pixel.preprocessing.parcel_to_pixel.convert_geodataframe_to_xarray(geodataframe_in: str | GeoDataFrame | DataFrame, save_path: str, name: str, variable: str, data_type: str, global_attributes: List[dict] = []) None[source]

Convert geopandas GeoDataDrames of the parcel mode into xarray DataArray for the model calculations. The resulting xarray dataset has dimensions: y: 1, x: number of poygons (to make a 2D dataset).

Arguments

  1. geodataframe_in: Union[str, gpd.GeoDataFrame, pd.DataFrame]

    geodataframe or path to geodataframe to convert

  2. save_path: str

    save path of output xarray dataset

  3. name: str

    name of dataarray to save

  4. variable: str

    name of variable to extract to put in the ouput dataset

  5. data_type: str

    xarray datatype corresponding the the variable name, for correct saving of the dataset

  6. global_attribute: List[dict]

    list of optionnal attributes to add to the netCDF file, give a list of single element dictionnary {key: value}

Returns

None

Land Cover preprocessing

Additional processing can be done with the custom_inputs_pixel.ipynb or custom_inputs_parcel.ipynb notebooks found in the preprocessing directory.