spatialdata.models.ShapesModel#

class spatialdata.models.ShapesModel#

Attributes table#

ATTRS_KEY

GEOMETRY_KEY

GEOS_KEY

NAME_KEY

RADIUS_KEY

TRANSFORM_KEY

TYPE_KEY

Methods table#

parse(data, **kwargs)

Parse shapes data.

validate(data)

Validate data.

Attributes#

ShapesModel.ATTRS_KEY = 'spatialdata_attrs'#
ShapesModel.GEOMETRY_KEY = 'geometry'#
ShapesModel.GEOS_KEY = 'geos'#
ShapesModel.NAME_KEY = 'name'#
ShapesModel.RADIUS_KEY = 'radius'#
ShapesModel.TRANSFORM_KEY = 'transform'#
ShapesModel.TYPE_KEY = 'type'#

Methods#

ShapesModel.parse(data, **kwargs)#

Parse shapes data.

Parameters:
  • data (Any) –

    Data to parse:

    • If numpy.ndarray, it assumes the shapes are parsed as ragged arrays, in case of (Multi)`Polygons`. Therefore additional arguments offsets and geometry must be provided

    • if Path or str, it’s read as a GeoJSON file.

    • If geopandas.GeoDataFrame, it’s validated. The object needs to have a column called geometry which is a geopandas.GeoSeries or shapely objects. Valid options are combinations of Polygon/ MultiPolygon or Point. If the geometries are Point, there must be another column called radius.

  • geometry

    Geometry type of the shapes. The following geometries are supported:

    • 0: Circles

    • 3: Polygon

    • 6: MultiPolygon

  • offsets – In the case of (Multi)`Polygons` shapes, in order to initialize the shapes from their ragged array representation, the offsets of the polygons must be provided. Alternatively you can call the parser as ShapesModel.parse(data), where data is a GeoDataFrame object and ignore the offset paramter (recommended).

  • radius – Size of the Circles. It must be provided if the shapes are Circles.

  • index – Index of the shapes, must be of type str. If None, it’s generated automatically.

  • transformations – Transformations of shapes.

  • kwargs (Any) – Additional arguments for GeoJSON reader.

Return type:

GeoDataFrame

Returns:

: geopandas.GeoDataFrame

classmethod ShapesModel.validate(data)#

Validate data.

Parameters:

data (GeoDataFrame) – geopandas.GeoDataFrame to validate.

Return type:

None

Returns:

: None