earthdaily.earthdatastore.cube_utils.geometry_manager module

class earthdaily.earthdatastore.cube_utils.geometry_manager.GeometryManager(geometry)[source]

Bases: object

A class to manage and convert various types of geometries into different formats.

Parameters:

geometry (various types) – Input geometry, can be GeoDataFrame, GeoSeries, WKT string, or GeoJSON.

geometry

The input geometry provided by the user.

Type:

various types

_obj

The geometry converted into a GeoDataFrame.

Type:

GeoDataFrame

input_type

Type of input geometry inferred during processing.

Type:

str

__call__():

Returns the stored GeoDataFrame.

to_intersects(crs='EPSG:4326'):

Converts geometry to GeoJSON intersects format with a specified CRS.

to_wkt(crs='EPSG:4326'):

Converts geometry to WKT format with a specified CRS.

to_json(crs='EPSG:4326'):

Converts geometry to GeoJSON format with a specified CRS.

to_geopandas():

Returns the GeoDataFrame of the input geometry.

to_bbox(crs='EPSG:4326'):

Returns the bounding box of the geometry with a specified CRS.

buffer_in_meter(distance, crs_meters='EPSG:3857', \*\*kwargs):

Applies a buffer in meters to the geometry and returns it with the original CRS.

buffer_in_meter(distance: int, crs_meters: str = 'EPSG:3857', **kwargs)[source]

Applies a buffer in meters to the geometry and returns it with the original CRS.

Parameters:
  • distance (int) – The buffer distance in meters.

  • crs_meters (str, optional) – The CRS to use for calculating the buffer (default is EPSG:3857).

  • **kwargs (dict, optional) – Additional keyword arguments to pass to the buffer method.

Returns:

The buffered geometry in the original CRS.

Return type:

GeoSeries

to_bbox(crs='EPSG:4326')[source]

Returns the bounding box of the geometry.

Parameters:

crs (str, optional) – The CRS to convert to (default is EPSG:4326).

Returns:

The bounding box as an array [minx, miny, maxx, maxy].

Return type:

numpy.ndarray

to_geopandas()[source]

Converts the input geometry to a GeoDataFrame.

Returns:

The input geometry as a GeoDataFrame.

Return type:

GeoDataFrame

to_intersects(crs='EPSG:4326')[source]

Converts the geometry to GeoJSON intersects format.

Parameters:

crs (str, optional) – The coordinate reference system (CRS) to convert to (default is EPSG:4326).

Returns:

The geometry in GeoJSON intersects format.

Return type:

dict

to_json(crs='EPSG:4326')[source]

Converts the geometry to GeoJSON format.

Parameters:

crs (str, optional) – The CRS to convert to (default is EPSG:4326).

Returns:

The geometry in GeoJSON format.

Return type:

dict

to_wkt(crs='EPSG:4326')[source]

Converts the geometry to WKT format.

Parameters:

crs (str, optional) – The CRS to convert to (default is EPSG:4326).

Returns:

The geometry in WKT format. If there is only one geometry, a single WKT string is returned; otherwise, a list of WKT strings.

Return type:

str or list of str