sepal_ui.aoi.aoi_model.AoiModel#

class sepal_ui.aoi.aoi_model.AoiModel(**kwargs)[source]#

An Model object dedicated to the sorage and the manipulation of aoi.

It is meant to be used with the AoiView object (embedded in the AoiTile). By using this you will be able to provide your application with aoi as an ee_object or a gdf, depending if you activated the ee binding or not. The class also provide insight on your aoi geometry.

Parameters:
  • gee (bool) – whether or not the aoi selector should be using the EarthEngine binding

  • vector (str | Path | None) – the path to the default vector object

  • admin (Unicode) – the administrative code of the default selection. Need to be GADM if ee==False and GAUL 2015 if ee==True.

  • asset (str | Path | None) – the default asset. Can only work if ee==True

  • folder (str | Path) – the init GEE asset folder where the asset selector should start looking (debugging purpose)

Deprecated since version 2.3.2: ‘asset_name’ will be used as variable to store ‘ASSET’ method info. To get the destination saved asset id, please use ‘dst_asset_id’ variable.

Attributes

ADMIN

The word displayed for admin method in the relevant lang

ASSET_SUFFIX

The suffix to identify the asset in GEE

CUSTOM

The word displayed for custom method in the relevant lang

MAPPING

GAUL -> ISO-3 mapping of country code

METHODS

The word displayed for all selection methods in the relevant lang

admin

The admin number selected

asset_json

The asset json description (only for GEE model)

asset_name

The asset name (only for GEE model)

default_admin

The default administrative area in GADM or GAUL norm

default_asset

The default asset name, need to point to a readable FeatureCollection

default_vector

The default vector file that will be used to produce the gdf.

dst_asset_id

The exported asset id

feature_collection

The feature Collection generated by the parameters (only for GEE models)

folder

The folder name used in GEE related component, mainly used for debugging

gdf

The geodataframe corresponding to the selected AOI

gee

either or not the model is bound to gee

geo_json

the drawn geojson shape

ipygeojson

The representation of the AOI as a ipyleaflet layer

method

the currently selected method

name

The name of the file to create (used only in drawn shaped)

point_json

information that will be use to transform the csv into a gdf

selected_feature

The Feature associated with a query

vector_json

information that will be use to transform the vector file into a gdf

Methods

__init__

An Model object dedicated to the sorage and the manipulation of aoi.

clear_attributes

Return all attributes to their default state.

clear_output

Clear the output of the aoi selector without changing the traits and/or the parameters.

export_to_asset

Export the feature_collection as an asset (only for ee model).

get_columns

Retrieve the columns or variables from self excluding geometries and gee index.

get_fields

Retrieve the fields from a column.

get_ipygeojson

Converts current geopandas object into ipyleaflet GeoJSON.

get_selected

Select an ee object based on selected column and field.

set_default

Set the default value of the object and create a gdf/feature_collection out of it.

set_object

Set the object (gdf/featurecollection) based on the model inputs.

total_bounds

Reproduce the behaviour of the total_bounds method from geopandas.

AoiModel.__init__(gee=True, vector=None, asset=None, admin=None, folder='')[source]#

An Model object dedicated to the sorage and the manipulation of aoi.

It is meant to be used with the AoiView object (embedded in the AoiTile). By using this you will be able to provide your application with aoi as an ee_object or a gdf, depending if you activated the ee binding or not. The class also provide insight on your aoi geometry.

Parameters:
  • gee (bool) – whether or not the aoi selector should be using the EarthEngine binding

  • vector (str | Path | None) – the path to the default vector object

  • admin (str | None) – the administrative code of the default selection. Need to be GADM if ee==False and GAUL 2015 if ee==True.

  • asset (str | Path | None) – the default asset. Can only work if ee==True

  • folder (str | Path) – the init GEE asset folder where the asset selector should start looking (debugging purpose)

Return type:

None

Deprecated since version 2.3.2: ‘asset_name’ will be used as variable to store ‘ASSET’ method info. To get the destination saved asset id, please use ‘dst_asset_id’ variable.

AoiModel.clear_attributes()[source]#

Return all attributes to their default state.

Note

Set the default setting as current object.

Return type:

Self

AoiModel.clear_output()[source]#

Clear the output of the aoi selector without changing the traits and/or the parameters.

Return type:

Self

AoiModel.export_to_asset()[source]#

Export the feature_collection as an asset (only for ee model).

Return type:

Self

AoiModel.get_columns()[source]#

Retrieve the columns or variables from self excluding geometries and gee index.

Returns:

sorted list of column names

Return type:

List[str]

AoiModel.get_fields(column)[source]#

Retrieve the fields from a column.

Parameters:
  • asset (A column name to query over the)

  • column (str)

Returns:

sorted list of fields value

Return type:

List[str]

AoiModel.get_ipygeojson(style=None)[source]#

Converts current geopandas object into ipyleaflet GeoJSON.

Parameters:

style (dict | None) – the predefined style of the aoi. It’s by default using a “success” sepal_ui.color with 0.5 transparent fill color. It can be completely replace by a fully qualified style dictionary. Use the sepal_ui.color object to define any color to remain compatible with light and dark theme.

Returns:

The geojson layer of the aoi gdf, ready to use in a Map

Return type:

GeoJSON

AoiModel.get_selected(column, field)[source]#

Select an ee object based on selected column and field.

Parameters:
  • column (str) – the selected column in the dataset

  • field (str) – the value to search in the selected column

Returns:

The Feature associated with the query

Return type:

Feature | GeoDataFrame

AoiModel.set_default(vector=None, admin=None, asset=None)[source]#

Set the default value of the object and create a gdf/feature_collection out of it.

Parameters:
  • vector (str | Path | None) – the default vector file that will be used to produce the gdf. need to be readable by fiona and/or GDAL/OGR

  • admin (str | None) – the default administrative area in GADM or GAUL norm

  • asset (str | Path | None) – the default asset name, need to point to a readable FeatureCollection

Return type:

Self

AoiModel.set_object(method='')[source]#

Set the object (gdf/featurecollection) based on the model inputs.

The method can be manually overwritten by setting the method parameter.

Parameters:

method (str) – a model loading method

Return type:

Self

AoiModel.total_bounds()[source]#

Reproduce the behaviour of the total_bounds method from geopandas.

Returns:

minxx, miny, maxx, maxy

Return type:

Tuple[float, float, float, float]