Source code for sensai.geoanalytics.geopandas.coordinates
import geopandas as gp
import numpy as np
from abc import ABC, abstractmethod
from shapely.geometry import MultiPoint
from typing import Union
from ...clustering import EuclideanClusterer
TCoordinates = Union[np.ndarray, MultiPoint, gp.GeoDataFrame, EuclideanClusterer.Cluster]
[docs]def validate_coordinates(coordinates: np.ndarray):
# for the moment we only support 2-dim coordinates. We can adjust it in the future when needed
if not len(coordinates.shape) == 2 or coordinates.shape[1] != 2:
raise Exception(f"Coordinates must be of shape (n, 2), instead got: {coordinates.shape}")
[docs]class GeoDataFrameWrapper(ABC):
[docs] @abstractmethod
def to_geodf(self, *args, **kwargs) -> gp.GeoDataFrame:
pass
[docs] def plot(self, *args, **kwargs):
self.to_geodf().plot(*args, **kwargs)