ecoscope.io.async_earthranger#

Module Contents#

class ecoscope.io.async_earthranger.AsyncEarthRangerIO(sub_page_size=4000, tcp_limit=5, **kwargs)[source]#

Bases: erclient.client.AsyncERClient

AsyncERClient asynchronous usage of EarthRanger server API (asyncio). Notice: This client is experimental and only supports a reduced set of features. ToDo: Move common logic from async and syc clients into a common place such as a base class

sub_page_size = 4000#
tcp_limit = 5#
event_type_display_values = None#
classmethod create(**kwargs)[source]#
Async:

async _init_client()[source]#
async get_me()[source]#
async get_sources(manufacturer_id=None, provider_key=None, provider=None, id=None, **addl_kwargs)[source]#
Parameters:
  • manufacturer_id

  • provider_key

  • providers

  • id

Return type:

An async generator to iterate over sources.

async get_sources_dataframe(manufacturer_id=None, provider_key=None, provider=None, id=None, **addl_kwargs)[source]#
Parameters:
  • manufacturer_id

  • provider_key

  • providers

  • id

Returns:

sources – DataFrame of queried sources

Return type:

pd.DataFrame

async get_subjects(include_inactive=None, bbox=None, subject_group_id=None, name=None, updated_since=None, tracks=None, id=None, updated_until=None, subject_group_name=None, **addl_kwargs)[source]#
Parameters:
  • include_inactive (Include inactive subjects in list.)

  • bbox (Include subjects having track data within this bounding box defined by a 4-tuple of coordinates marking) – west, south, east, north.

  • subject_group_id (Indicate a subject group id for which Subjects should be listed.) – This is translated to the subject_group parameter in the ER backend

  • name (Find subjects with the given name)

  • updated_since (Return Subject that have been updated since the given timestamp.)

  • tracks (Indicate whether to render each subject's recent tracks.)

  • id (A comma-delimited list of Subject IDs.)

  • updated_until

  • subject_group_name (A subject group name for which Subjects should be listed.) – This is translated to the group_name parameter in the ER backend

Return type:

An async generator to iterate over subjects

async get_subjects_dataframe(include_inactive=None, bbox=None, subject_group_id=None, name=None, updated_since=None, tracks=None, id=None, updated_until=None, subject_group_name=None, **addl_kwargs)[source]#
Parameters:
  • include_inactive (Include inactive subjects in list.)

  • bbox (Include subjects having track data within this bounding box defined by a 4-tuple of coordinates marking) – west, south, east, north.

  • subject_group_id (Indicate a subject group id for which Subjects should be listed.) – This is translated to the subject_group parameter in the ER backend

  • name (Find subjects with the given name)

  • updated_since (Return Subject that have been updated since the given timestamp.)

  • tracks (Indicate whether to render each subject's recent tracks.)

  • id (A comma-delimited list of Subject IDs.)

  • updated_until

  • subject_group_name (A subject group name for which Subjects should be listed.) – This is translated to the group_name parameter in the ER backend

Returns:

subjects

Return type:

pd.DataFrame

async get_subjectsources(subjects=None, sources=None, **addl_kwargs)[source]#
Parameters:
  • subjects (A comma-delimited list of Subject IDs.)

  • sources (A comma-delimited list of Source IDs.)

Return type:

An async generator to iterate over subjectsources

async get_subjectsources_dataframe(subjects=None, sources=None, **addl_kwargs)[source]#
Parameters:
  • subjects (A comma-delimited list of Subject IDs.)

  • sources (A comma-delimited list of Source IDs.)

Returns:

subjectsources

Return type:

pd.DataFrame

async get_patrol_types_dataframe()[source]#
async get_patrols(since=None, until=None, patrol_type=None, status=None, **addl_kwargs)[source]#
Parameters:
  • since – lower date range

  • until – upper date range

  • patrol_type – Comma-separated list of type of patrol UUID

  • status – Comma-separated list of ‘scheduled’/’active’/’overdue’/’done’/’cancelled’

Returns:

patrols – DataFrame of queried patrols

Return type:

pd.DataFrame

async get_patrols_dataframe(**kwargs)[source]#
async get_observations(source_ids=None, subject_ids=None, subjectsource_ids=None, tz='UTC', since=None, until=None, filter=None, include_details=None, created_after=None, **addl_kwargs)[source]#

Return observations matching queries. If subject_id, source_id, or subjectsource_id is specified, the index is set to the provided value. :param subject_ids: :type subject_ids: filter to a single subject :param source_ids: :type source_ids: filter to a single source :param subjectsource_ids: :type subjectsource_ids: filter to a subjectsource_id, rather than source_id + time range :param since: :type since: get observations after this ISO8061 date, include timezone :param until: :type until: get observations up to this ISO8061 date, include timezone :param filter: filter using exclusion_flags for an observation.

filter=None returns everything filter=0 filters out everything but rows with exclusion flag 0 (i.e, passes back clean data) filter=1 filters out everything but rows with exclusion flag 1 (i.e, passes back manually filtered data) filter=2, filters out everything but rows with exclusion flag 2 (i.e., passes back automatically filtered data) filter=3, filters out everything but rows with exclusion flag 2 or 1 (i.e., passes back both manual and automatically filtered data)

Parameters:
  • include_details (one of [true,false], default is false. This brings back the observation additional field)

  • created_after (get observations created (saved in EarthRanger) after this ISO8061 date, include timezone)

Returns:

observations

Return type:

gpd.GeoDataFrame

async get_observations_gdf(**kwargs)[source]#
async get_patrol_observations_with_patrol_filter(since=None, until=None, patrol_type=None, status=None, include_patrol_details=False, relocations=True, tz='UTC', **kwargs)[source]#

Download observations for patrols with provided filters. :param since: lower date range :param until: upper date range :param patrol_type: Comma-separated list of type of patrol UUID :param status: Comma-separated list of ‘scheduled’/’active’/’overdue’/’done’/’cancelled’ :param include_patrol_details: Whether to merge patrol details into dataframe :type include_patrol_details: bool, optional :param kwargs: Additional parameters to pass to _get_observations_by_patrol.

Returns:

relocations

Return type:

ecoscope.base.Relocations

async _get_observations_by_patrol(patrol, relocations=True, tz='UTC', patrol_types=None, **kwargs)[source]#

Download observations by patrol. :param patrol: The patrol to download observations for :param relocations: If true, returns a ecoscope.base.Relocations object instead of a GeoDataFrame :param tz: The timezeone to return observation times in :param patrol_types: Comma-separated list of type of patrol UUID :param kwargs: Additional parameters to pass to get_observations.

Returns:

relocations

Return type:

ecoscope.base.Relocations

async get_events_dataframe(is_collection=None, updated_size=None, event_ids=None, bbox=None, sort_by=None, patrol_segment=None, state=None, event_type=None, include_updates=False, include_details=False, include_notes=False, include_related_events=False, include_files=False, max_results=None, oldest_update_date=None, exclude_contained=None, updated_since=None, event_category=None, since=None, until=None, **addl_kwargs)[source]#
Parameters:
  • is_collection – true/false whether to filter on is_collection

  • updated_since – date-string to limit on updated_at

  • event_ids (array[string]) – Event IDs, comma-separated

  • bbox – bounding box including four coordinate values, comma-separated. Ex. bbox=-122.4,48.4,-122.95,49.0 (west, south, east, north).

  • sort_by – Sort by (use ‘event_time’, ‘updated_at’, ‘created_at’, ‘serial_number’) with optional minus (‘-’) prefix to reverse order.

  • patrol_segment – ID of patrol segment to filter on

  • state – Comma-separated list of ‘scheduled’/’active’/’overdue’/’done’/’cancelled’

  • event_type – Comma-separated list of event type uuids

  • include_updates – Boolean value

  • include_details – Boolean value

  • include_notes – Boolean value

  • include_related_events – Boolean value

  • include_files – Boolean value

  • max_results

  • oldest_update_date

  • exclude_contained

  • event_category

  • since

  • until

Returns:

events – GeoDataFrame of queried events

Return type:

gpd.GeoDataFrame

async get_event_types(include_inactive=False, **addl_kwargs)[source]#
Parameters:
  • include_inactive (Include inactive subjects in list.)

  • **addl_kwargs (Additional query params)

Return type:

An async generator to iterate over event types

async get_event_schema(event_type_name)[source]#
Parameters:

event_type_name (The event type to fetch)

Return type:

The event type schema json

async load_display_map()[source]#

Loads event type display values into event_type_display_values

async get_event_type_display_name(event_type, event_property=None)[source]#
Parameters:
  • event_type (The event type name to fetch the display value of)

  • event_property (If provided, returns the display name of the provided event property)