src.digitaltwin.arcgis_rest_api

This script provides functions to interact with ArcGIS REST API feature layers, generate query parameters, and retrieve geographic data for a specified area of interest.

Attributes

log

Classes

RecordCounts

Represents the record counts of the feature layer.

Functions

get_feature_layer_record_counts(→ RecordCounts)

Retrieve the maximum and total record counts from the feature layer.

gen_query_param_list(→ List[Dict[str, Union[str, int]]])

Generate a list of API query parameters used to retrieve ArcGIS REST API data.

_fetch_geo_data(→ geopandas.GeoDataFrame)

Fetch geographic data using the provided query parameters within a single API call.

fetch_geo_data_for_aoi(→ geopandas.GeoDataFrame)

Retrieve geographic data for the area of interest using the ArcGIS REST API.

fetch_arcgis_rest_api_data(→ geopandas.GeoDataFrame)

Retrieve geographic data for the area of interest using the ArcGIS REST API.

Module Contents

src.digitaltwin.arcgis_rest_api.log
class src.digitaltwin.arcgis_rest_api.RecordCounts

Bases: NamedTuple

Represents the record counts of the feature layer.

max_record_count

The maximum number of records that will be returned per query.

Type:

int

total_record_count

The total number of records available in the feature layer.

Type:

int

max_record_count: int
total_record_count: int
src.digitaltwin.arcgis_rest_api.get_feature_layer_record_counts(url: str) RecordCounts

Retrieve the maximum and total record counts from the feature layer.

Parameters:

url (str) – The URL of the feature layer.

Returns:

A named tuple containing the maximum and total record counts of the feature layer.

Return type:

RecordCounts

Raises:

RuntimeError – If there is an issue with retrieving the record counts from the feature layer.

src.digitaltwin.arcgis_rest_api.gen_query_param_list(url: str, area_of_interest: geopandas.GeoDataFrame = None, output_sr: int = None) List[Dict[str, str | int]]

Generate a list of API query parameters used to retrieve ArcGIS REST API data.

Parameters:
  • url (str) – The URL of the feature layer.

  • area_of_interest (gpd.GeoDataFrame = None) – A GeoDataFrame representing the area of interest for data retrieval. If not provided, all data will be fetched.

  • output_sr (int = None) – The EPSG code of the spatial reference system in which the requested data should be returned if no area of interest is provided.

Returns:

A list of API query parameters used to retrieve ArcGIS REST API data.

Return type:

List[Dict[str, Union[str, int]]]

Raises:

ValueError – If output_sr is provided when area_of_interest is given.

async src.digitaltwin.arcgis_rest_api._fetch_geo_data(session: aiohttp.ClientSession, url: str, query_param: Dict[str, str | int]) geopandas.GeoDataFrame

Fetch geographic data using the provided query parameters within a single API call.

Parameters:
  • session (aiohttp.ClientSession) – An instance of aiohttp.ClientSession used for making HTTP requests.

  • url (str) – The URL of the feature layer.

  • query_param (Dict[str, Union[str, int]]) – The query parameters used to retrieve geographic data.

Returns:

A GeoDataFrame containing the fetched geographic data.

Return type:

gpd.GeoDataFrame

async src.digitaltwin.arcgis_rest_api.fetch_geo_data_for_aoi(url: str, area_of_interest: geopandas.GeoDataFrame = None, output_sr: int = None) geopandas.GeoDataFrame

Retrieve geographic data for the area of interest using the ArcGIS REST API.

Parameters:
  • url (str) – The URL of the feature layer.

  • area_of_interest (gpd.GeoDataFrame = None) – A GeoDataFrame representing the area of interest for data retrieval. If not provided, all data will be fetched.

  • output_sr (int = None) – The EPSG code of the spatial reference system in which the requested data should be returned if no area of interest is provided.

Returns:

A GeoDataFrame containing the fetched geographic data for the area of interest.

Return type:

gpd.GeoDataFrame

src.digitaltwin.arcgis_rest_api.fetch_arcgis_rest_api_data(url: str, area_of_interest: geopandas.GeoDataFrame = None, output_sr: int = None) geopandas.GeoDataFrame

Retrieve geographic data for the area of interest using the ArcGIS REST API.

Parameters:
  • url (str) – The URL of the feature layer.

  • area_of_interest (gpd.GeoDataFrame = None) – A GeoDataFrame representing the area of interest for data retrieval. If not provided, all data will be fetched.

  • output_sr (int = None) – The EPSG code of the spatial reference system in which the requested data should be returned if no area of interest is provided.

Returns:

A GeoDataFrame containing the fetched geographic data for the area of interest.

Return type:

gpd.GeoDataFrame

Raises:

RuntimeError – If failed to fetch geographic data for the area of interest.