Elementary API endpoints

dyancrop.sdk module

class dynacrop.sdk.User

Bases: dynacrop.api_handles.APIObject, dynacrop.attrs.user.UserAttrs

User endpoint object

class dynacrop.sdk.Polygon(id: Optional[int] = None, ext_data: Optional[dict] = None)

Bases: dynacrop.api_handles.APIObject, dynacrop.attrs.polygon.PolygonAttrs

Polygon endpoint object

classmethod create(geometry: str, label: Optional[str] = None, max_mean_cloud_cover: Optional[int] = None, smi_enabled: bool = False, **kwargs) dynacrop.sdk.Polygon

Creates Polygon endpoint object.

Parameters
  • geometry (str) – Valid polygon shape in Well Known Text (WKT) representation (see: https://en.wikipedia.org/wiki/Well- known_text_representation_of_geometry).

  • label (Optional[str], optional) – Description to the Polygon (user field). Defaults to None.

  • max_mean_cloud_cover (Optional[int], optional) – Maximum mean cloud coverage in decimal percentage (i.e. 0.3). Defaults to None.

  • smi_enabled (bool, optional) – To enable Soil Moisture Index pre-computation. Defaults to False.

Returns

APIObject instantiated into Polygon child.

Return type

Polygon

static as_geodataframe(polygons: list, fields: list = ['id', 'area', 'last_valid_observation', 'smi_enabled', 'max_mean_cloud_cover', 'label', 'valid_observations', 'cloud_cover_percent', 'last_updated', 'created_date', 'completed_date', 'last_updated'], iterables_to_strings: Optional[bool] = True) geopandas.geodataframe.GeoDataFrame

Create a Geopandas GeoDataFrame from a list of Polygon objects. This can be then saved to a file by GeoDataFrame to_file method.

Parameters
  • polygons (list) – A list of polygons to create the GeoDataFrame from.

  • fields (Optional[list], optional) – Polygon attributes that will be represented as fields in the GeoDataFrame. Iterable attributes are converted to string for save . Defaults to [“id”, “area”, “last_valid_observation”, “smi_enabled”, “max_mean_cloud_cover” , “label”, “valid_observations”, “cloud_cover_percent”, “last_updated”, “created_date”, “completed_date”, “last_updated “].

  • iterables_to_strings (Optional[bool], optional) – If True, all iterable Polygon attributes will be converted to strings for saving purposes. Spatial files usually reject saving Python iterables to attribute tables.

Returns

GeoDataFrame of polygons.

Return type

GeoDataFrame

class dynacrop.sdk.TimeSeries(id: Optional[int] = None, ext_data: Optional[dict] = None)

Bases: dynacrop.processing_request_base.JSONProcessingRequest

Time series endpoint object. Time series is the service of DynaCrop API.

rendering_type = 'time_series'
classmethod create(polygon: dynacrop.sdk.Polygon, layer: dynacrop.constants.Layer, date_from: str, date_to: str) dynacrop.sdk.TimeSeries

Creates Time series endpoint object.

Parameters
  • polygon (Polygon) – Polygon endpoint object.

  • layer (str) – Should be Layer enumration. One of the DynaCrop API layers. See https://dynacrop.worldfromspace.cz/docs/#/products for further information.

  • date_from (str) – Date to record time series from.

  • date_to (str) – Date to record time series to.

Returns

APIObject instatiated into TimeSeries child.

Return type

APIObject

class dynacrop.sdk.Observation(id: Optional[int] = None, ext_data: Optional[dict] = None)

Bases: dynacrop.processing_request_base.ObservationBase

Observation endpoint object. Observation is the service of DynaCrop API.

rendering_type = 'observation'
classmethod create(polygon: dynacrop.sdk.Polygon, layer: dynacrop.constants.Layer, date_from: str, date_to: str) dynacrop.sdk.Observation

Creates Observation endpoint object.

Parameters
  • polygon (Polygon) – Polygon endpoint object.

  • layer (str) – Should be Layer enumration. One of the DynaCrop API layers. See https://dynacrop.worldfromspace.cz/docs/#/products for further information.

  • date_from (str) – Date to watch for observation from.

  • date_to (str) – Date to watch for observation to.

Returns

APIObject instatiated into Observation child.

Return type

APIObject

class dynacrop.sdk.FieldZonation(id: Optional[int] = None, ext_data: Optional[dict] = None)

Bases: dynacrop.processing_request_base.FieldZonationBase

Field zonation endpoint object. Field zonation is the service of DynaCrop API.

rendering_type = 'field_zonation'
classmethod create(polygon: dynacrop.sdk.Polygon, layer: dynacrop.constants.Layer, date_from: str, date_to: str, number_of_zones: int = 3) dynacrop.sdk.FieldZonation

Creates Field zonation endpoint object.

Parameters
  • polygon (Polygon) – Polygon endpoint object.

  • layer (str) – Should be Layer enumration. One of the DynaCrop API layers. See https://dynacrop.worldfromspace.cz/docs/#/products for further information.

  • date_from (str) – Date to compute field zonation from.

  • date_to (str) – Date to compute field zonation to.

  • number_of_zones (int) – Number of zones to separate the field to. The number of zones must be one of 3, 5, 10, 20, 255.

Returns

APIObject instatiated into FieldZonation child.

Return type

APIObject

class dynacrop.sdk.FieldZonationByMedian(id: Optional[int] = None, ext_data: Optional[dict] = None)

Bases: dynacrop.processing_request_base.FieldZonationBase

Field zonation by median endpoint object. Field zonation by median is the service of DynaCrop API.

rendering_type = 'field_zonation_by_median'
classmethod create(polygon: dynacrop.sdk.Polygon, layer: dynacrop.constants.Layer, date_from: str, date_to: str, thresholds: Optional[list] = None) dynacrop.sdk.FieldZonationByMedian

Creates Field zonation by median endpoint object.

Parameters
  • polygon (Polygon) – Polygon endpoint object.

  • layer (str) – Should be Layer enumration. One of the DynaCrop API layers. See https://dynacrop.worldfromspace.cz/docs/#/products for further information.

  • date_from (str) – Date to compute field zonation by median from.

  • date_to (str) – Date to compute field zonation by median to.

  • thresholds (list) – Thresholds to zone the field in between. The number of thresholds must be one of 2, 4, 9, 19, 254.

Returns

APIObject instatiated into FieldZonationByMedian child.

Return type

APIObject

dynacrop.processing_request_base module

class dynacrop.processing_request_base.ProcessingRequest(id: Optional[int] = None, ext_data: Optional[dict] = None)

Bases: dynacrop.api_handles.APIObject, dynacrop.attrs.processing_request.ProcessingRequestAttrs

Processing request endpoint object

refresh()

Updates the response data of the Processing request.

Raises

InvalidRenderingTypeError – If an already-created processing request is a different rendering type than requested.

classmethod create(**kwargs) dynacrop.api_handles.APIObject

Creates Processing request endpoint object.

Returns

APIObject instatiated into ProcessingRequest child.

Return type

APIObject

classmethod validate(kwargs: dict)

Validates Processing request result status.

Parameters

kwargs (dict) –

Raises

PolygonNotReadyForProcessingError – If the Processing request is created or requested while the target Polygon is not yet processed.

static correct_dates(dates: list) list

Checks if dates need to be corrected and does so.

Parameters

dates (list) – Dates within a processing request.

Returns

List with converted dates.

Return type

tuple

static convert_date_to_str(date: datetime.datetime) str

Converts datetime.date to string if necessary

Parameters

date (datetime) – Date in datetime.datetime format.

Returns

Date in string format.

Return type

str

has_data() bool

Checks whether the Processing request returned any data.

Returns

Data filling statetment.

Return type

bool