pysepal.aoi.aoi_model.AoiModel#
- class pysepal.aoi.aoi_model.AoiModel(*args, **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)
gee_session (EESession | None) – the Earth Engine session to use for the GEE binding (deprecated in favor of gee_interface)
gee_interface (GEEInterface | None) – a shared GEEInterface instance. If provided, takes precedence over gee_session
- Raises:
ValueError – if both gee_session and gee_interface are provided
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.
Added in version 3.0.0: Added gee_interface parameter for sharing GEEInterface instances across components.
Attributes
ADMINThe word displayed for admin method in the relevant lang
ASSET_SUFFIXThe suffix to identify the asset in GEE
CUSTOMThe word displayed for custom method in the relevant lang
MAPPINGGAUL -> ISO-3 mapping of country code
METHODSThe word displayed for all selection methods in the relevant lang
adminThe admin number selected
asset_jsonThe asset json description (only for GEE model)
asset_nameThe asset name (only for GEE model)
default_adminThe default administrative area in GADM or GAUL norm
default_assetThe default asset name, need to point to a readable FeatureCollection
default_vectorThe default vector file that will be used to produce the gdf.
dst_asset_idThe exported asset id
feature_collectionThe feature Collection generated by the parameters (only for GEE models)
folderThe folder name used in GEE related component, mainly used for debugging
gdfThe geodataframe corresponding to the selected AOI
geeeither or not the model is bound to gee
geo_jsonthe drawn geojson shape
ipygeojsonThe representation of the AOI as a ipyleaflet layer
methodthe currently selected method
nameThe name of the file to create (used only in drawn shaped)
object_setAn integer that is incremented each time the object is set..
point_jsoninformation that will be use to transform the csv into a gdf
selected_featureThe Feature associated with a query
vector_jsoninformation that will be use to transform the vector file into a gdf
Methods
An Model object dedicated to the sorage and the manipulation of aoi.
Return all attributes to their default state.
Clear the output of the aoi selector without changing the traits and/or the parameters.
Export the feature_collection as an asset (only for ee model).
Export the feature_collection as an asset (only for ee model).
Retrieve the columns or variables from self excluding geometries and gee index.
Retrieve the fields from a column.
Converts current geopandas object into ipyleaflet GeoJSON.
Select an ee object based on selected column and field.
Set the default value of the object and create a gdf/feature_collection out of it.
Set the object (gdf/featurecollection) based on the model inputs.
Reproduce the behaviour of the total_bounds method from geopandas.
- AoiModel.__init__(gee=True, vector=None, asset=None, admin=None, folder='', gee_session=None, gee_interface=None)[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)
gee_session (EESession | None) – the Earth Engine session to use for the GEE binding (deprecated in favor of gee_interface)
gee_interface (GEEInterface | None) – a shared GEEInterface instance. If provided, takes precedence over gee_session
- Raises:
ValueError – if both gee_session and gee_interface are provided
- 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.
Added in version 3.0.0: Added gee_interface parameter for sharing GEEInterface instances across components.
- 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
- async AoiModel.export_to_asset_async()[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.colorwith 0.5 transparent fill color. It can be completely replace by a fully qualified style dictionary. Use thesepal_ui.colorobject 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