Welcome to Spiky’s documentation!

Spiky

Spiky removes spikes from GeoPackage shapes.

param inputfile

Input GeoPackage file (path or file in cwd)

Kwargs:

-a, –angle: Maximum angle of spikes (degrees) -v, –verbose: Print debug log messages

Output:

Geopackage in folder of inputfile with ‘_ds’ suffix: {inputfile}_ds.gpkg

Example

$ spiky.py spiky-polygon.gpkg -a 1

spiky.calculate_angle(a: tuple, b: tuple, c: tuple) → float

Calculates the absolute geographic angle of point b with regards to neighbouring points a and c.

Points should be in WGS84 Geographic coordinates.

Parameters
  • a – Neighbouring point a (xy tuple).

  • b – Center point b (xy tuple).

  • c – Neighbouring point c (xy tuple).

Returns

The absolute angle.

spiky.cmd_line_parse(args) → argparse.Namespace

Parses command line input and returns argument object

Returns

args

spiky.conf_logger(verbose: bool)

‘Configure Spiky’s logging level

spiky.despike_gdf(package_gdf: geopandas.GeoDataFrame, angle: float = 1, verbose: bool = False) → geopandas.GeoDataFrame

Despikes all shapes in a GeoDataFrame.

Parameters
  • package_gdf – Input GeoPackage object

  • angle – Maximum angle of spikes (degrees).

Returns

Despiked GeoPackage object

spiky.despike_list(coord_list: list, angle: float = 1) → list

Removes spikes from a coord list.

Spikes are vertices with neighbouring angles < min. Coordinates can be line or ring.

Parameters
  • coord_list – Input list of xy tuples to be despiked.

  • angle – Maximum angle of spikes (degrees).

Returns

Despiked coord list.

spiky.despike_shape(shape: shapely.geometry, angle: float = 1) → shapely.geometry

Removes spikes from various shapely geometries.

Deconstructs shape’s CoordSequences into lists, despikes the lists and rebuilds the shape.

Currently supports only Polygons but Line, MultiLine and Multipolygon are possible.

Parameters
  • shape – Input shapely geometry.

  • angle – Maximum angle of spikes (degrees).

Returns

Despiked shape.

spiky.verify_gdf(package_gdf: geopandas.GeoDataFrame, name: str = 'File') → bool

Verifies GeoPandas GeoDataframe validity.

Parameters

shape – Input geopandas GeoDataframe.

Returns

True if file is valid.

Return type

bool

Raises

ValueError – If GeoDataframe file is not valid for Spiky.

Indices and tables