In this notebook you will learn about an interactive way of doing time series analysis of field, to understand the status of crops.
This notebook will require a number of external Python modules to run, which will be imported at the top of the notebook as his convention.
import sys
import datacube
import warnings
sys.path.append('/eOsphere/bin')
from dcFunctions import scal_2_tru, crop_health
As we have been showed in other notebooks, we need to initialise a datacube instance in order to have access to the Data Cube, and this can be done as follows:
dc = datacube.Datacube()
We need to define our area of interest and this can be done, either specifying the minimum and maximum latitude and longitude, or defining the centre coordinates plus a buffer
; which will be the number of square degrees to load around the central latitude and longitude.
lat, lon, buffer = 42.3, 75, 0.5
latitude = (lat - buffer, lat + buffer)
longitude = (lon - buffer, lon + buffer)
print(latitude,longitude)
Define a query to load the data from the datacube
query = {
'x': longitude,
'y': latitude,
'output_crs':'EPSG:32643',
'resolution':[-250, 250],
}
Load data from the already made NDVI 10-day product. You can change this so that you can do time series analysis on other datasets.
ds = dc.load(product='mcv_indices', measurements=['ndvi'], time=['2020-01-01','2020-10-31'], **query)
ds = scal_2_tru(ds) # Applying scaling to get real values
print(ds)
Now we can run the crop_health
function available in dcFunctions
.
As arguments you have to pass:
crop_health(data=ds, lat=latitude, lon=longitude, method='std')
If you want to use an RGB layer from the KDC then you will first need to load the data and then pass it to the crop_health
function.
query_high = {
'x': longitude,
'y': latitude,
'output_crs':'EPSG:32643',
'resolution':[-20, 20],
}
ds_rgb = dc.load(product='rgb',measurements=['red','green','blue'], time='2020-08-21', **query_high)
Now that you load the data from the KDC, you can pass to crop_health
as an additional argument.
crop_health(data=ds, lat=lat, lon=lon, buffer=buffer, ds_rgb=ds_rgb, method='mean')