Geos Series Accessor#

class pgpd.GeosSeriesAccessor(obj)#

Access shapely functionality through the “geos” series accessor keyword.

Example

>>> s = pd.Series(shapely.points(range(15), 0), dtype='geos')
>>> s
0    POINT (0 0)
1    POINT (1 0)
2    POINT (2 0)
3    POINT (3 0)
4    POINT (4 0)
5    POINT (5 0)
6    POINT (6 0)
7    POINT (7 0)
8    POINT (8 0)
9    POINT (9 0)
dtype: geos
>>> s.geos.has_z
0    False
1    False
2    False
3    False
4    False
5    False
6    False
7    False
8    False
9    False
Name: has_z, dtype: bool

Serialization#

Serialization & Deserialization functionality.

GeosSeriesAccessor.to_geos

Transform the series in a shapely geos column.

GeosSeriesAccessor.to_geopandas

Convert a geos Series into a geopandas.GeoSeries.

GeosSeriesAccessor.to_wkt

GeosSeriesAccessor.to_wkb

Geometry#

Methods from Shapely Geometry Properties.

GeosSeriesAccessor.get_coordinate_dimension

Returns the dimensionality of the coordinates in a geometry (2 or 3).

GeosSeriesAccessor.get_dimensions

Returns the inherent dimensionality of a geometry.

GeosSeriesAccessor.get_exterior_ring

Returns the exterior ring of a polygon.

GeosSeriesAccessor.get_geometry

Returns the nth geometry from a collection of geometries.

GeosSeriesAccessor.get_interior_ring

Returns the nth interior ring of a polygon.

GeosSeriesAccessor.get_num_coordinates

Returns the total number of coordinates in a geometry.

GeosSeriesAccessor.get_num_geometries

Returns number of geometries in a collection.

GeosSeriesAccessor.get_num_interior_rings

Returns number of internal rings in a polygon

GeosSeriesAccessor.get_num_points

Returns number of points in a linestring or linearring.

GeosSeriesAccessor.get_parts

Gets parts of each GeometryCollection or Multi* geometry object; returns a copy of each geometry in the GeometryCollection or Multi* geometry object.

GeosSeriesAccessor.get_point

Returns the nth point of a linestring or linearring.

GeosSeriesAccessor.get_precision

Get the precision of a geometry.

GeosSeriesAccessor.get_rings

Gets rings of Polygon geometry object.

GeosSeriesAccessor.get_srid

Returns the SRID of a geometry.

GeosSeriesAccessor.get_type_id

Returns the type ID of a geometry.

GeosSeriesAccessor.get_x

Returns the x-coordinate of a point

GeosSeriesAccessor.get_y

Returns the y-coordinate of a point

GeosSeriesAccessor.get_z

Returns the z-coordinate of a point.

GeosSeriesAccessor.force_2d

Forces the dimensionality of a geometry to 2D.

GeosSeriesAccessor.force_3d

Forces the dimensionality of a geometry to 3D.

GeosSeriesAccessor.set_precision

Returns geometry with the precision set to a precision grid size.

GeosSeriesAccessor.set_srid

Returns a geometry with its SRID set.

Geometry Creation#

Methods from Shapely Geometry Creation.

GeosSeriesAccessor.destroy_prepared

Destroy the prepared part of a geometry, freeing up memory.

GeosSeriesAccessor.prepare

Prepare a geometry, improving performance of other operations.

Measurement#

Methods from Shapely Measurement.

GeosSeriesAccessor.area

Computes the area of a (multi)polygon.

GeosSeriesAccessor.bounds

Computes the bounds (extent) of a geometry.

GeosSeriesAccessor.distance

Computes the Cartesian distance between two geometries.

GeosSeriesAccessor.frechet_distance

Compute the discrete Fréchet distance between two geometries.

GeosSeriesAccessor.hausdorff_distance

Compute the discrete Hausdorff distance between two geometries.

GeosSeriesAccessor.length

Computes the length of a (multi)linestring or polygon perimeter.

GeosSeriesAccessor.minimum_bounding_radius

Computes the radius of the minimum bounding circle that encloses an input geometry.

GeosSeriesAccessor.minimum_clearance

Computes the Minimum Clearance distance.

GeosSeriesAccessor.total_bounds

Computes the total bounds (extent) of the geometry.

Predicates#

Methods from Shapely Predicates.

GeosSeriesAccessor.contains

Returns True if geometry B is completely inside geometry A.

GeosSeriesAccessor.contains_properly

Returns True if geometry B is completely inside geometry A, with no common boundary points.

GeosSeriesAccessor.covered_by

Returns True if no point in geometry A is outside geometry B.

GeosSeriesAccessor.covers

Returns True if no point in geometry B is outside geometry A.

GeosSeriesAccessor.crosses

Returns True if A and B spatially cross.

GeosSeriesAccessor.disjoint

Returns True if A and B do not share any point in space.

GeosSeriesAccessor.equals

Returns True if A and B are spatially equal.

GeosSeriesAccessor.equals_exact

Returns True if A and B are structurally equal.

GeosSeriesAccessor.has_z

Returns True if a geometry has a Z coordinate.

GeosSeriesAccessor.intersects

Returns True if A and B share any portion of space.

GeosSeriesAccessor.is_ccw

Returns True if a linestring or linearring is counterclockwise.

GeosSeriesAccessor.is_closed

Returns True if a linestring's first and last points are equal.

GeosSeriesAccessor.is_empty

Returns True if a geometry is an empty point, polygon, etc.

GeosSeriesAccessor.is_geometry

Returns True if the object is a geometry

GeosSeriesAccessor.is_missing

Returns True if the object is not a geometry (None)

GeosSeriesAccessor.is_prepared

Returns True if a Geometry is prepared.

GeosSeriesAccessor.is_ring

Returns True if a linestring is closed and simple.

GeosSeriesAccessor.is_simple

Returns True if a Geometry has no anomalous geometric points, such as self-intersections or self tangency.

GeosSeriesAccessor.is_valid

Returns True if a geometry is well formed.

GeosSeriesAccessor.is_valid_input

Returns True if the object is a geometry or None

GeosSeriesAccessor.is_valid_reason

Returns a string stating if a geometry is valid and if not, why.

GeosSeriesAccessor.overlaps

Returns True if A and B spatially overlap.

GeosSeriesAccessor.relate

Returns a string representation of the DE-9IM intersection matrix.

GeosSeriesAccessor.relate_pattern

Returns True if the DE-9IM string code for the relationship between the geometries satisfies the pattern, else False.

GeosSeriesAccessor.touches

Returns True if the only points shared between A and B are on the boundary of A and B.

GeosSeriesAccessor.within

Returns True if geometry A is completely inside geometry B.

Set Operations#

Methods from Shapely Set Operations.

GeosSeriesAccessor.coverage_union

Merges multiple polygons into one.

GeosSeriesAccessor.coverage_union_all

Returns the union of multiple polygons of a geometry collection.

GeosSeriesAccessor.difference

Returns the part of geometry A that does not intersect with geometry B.

GeosSeriesAccessor.intersection

Returns the geometry that is shared between input geometries.

GeosSeriesAccessor.intersection_all

Returns the intersection of multiple geometries.

GeosSeriesAccessor.symmetric_difference

Returns the geometry that represents the portions of input geometries that do not intersect.

GeosSeriesAccessor.symmetric_difference_all

Returns the symmetric difference of multiple geometries.

GeosSeriesAccessor.union

Merges geometries into one.

GeosSeriesAccessor.union_all

Returns the union of multiple geometries.

Constructive Operations#

Methods from Shapely Constructive Operations.

GeosSeriesAccessor.boundary

Returns the topological boundary of a geometry.

GeosSeriesAccessor.buffer

Computes the buffer of a geometry for positive and negative buffer distance.

GeosSeriesAccessor.build_area

Creates an areal geometry formed by the constituent linework of given geometry.

GeosSeriesAccessor.centroid

Computes the geometric center (center-of-mass) of a geometry.

GeosSeriesAccessor.clip_by_rect

Returns the portion of a geometry within a rectangle.

GeosSeriesAccessor.convex_hull

Computes the minimum convex geometry that encloses an input geometry.

GeosSeriesAccessor.delaunay_triangles

Computes a Delaunay triangulation around the vertices of an input geometry.

GeosSeriesAccessor.envelope

Computes the minimum bounding box that encloses an input geometry.

GeosSeriesAccessor.extract_unique_points

Returns all distinct vertices of an input geometry as a multipoint.

GeosSeriesAccessor.make_valid

Repairs invalid geometries.

GeosSeriesAccessor.minimum_bounding_circle

Computes the minimum bounding circle that encloses an input geometry.

GeosSeriesAccessor.minimum_rotated_rectangle

Computes the oriented envelope (minimum rotated rectangle) that encloses an input geometry, such that the resulting rectangle has minimum area.

GeosSeriesAccessor.normalize

Converts Geometry to normal form (or canonical form).

GeosSeriesAccessor.offset_curve

Returns a (Multi)LineString at a distance from the object on its right or its left side.

GeosSeriesAccessor.oriented_envelope

Computes the oriented envelope (minimum rotated rectangle) that encloses an input geometry, such that the resulting rectangle has minimum area.

GeosSeriesAccessor.point_on_surface

Returns a point that intersects an input geometry.

GeosSeriesAccessor.polygonize

Creates polygons formed from the linework of a set of Geometries.

GeosSeriesAccessor.reverse

Returns a copy of a Geometry with the order of coordinates reversed.

GeosSeriesAccessor.segmentize

Adds vertices to line segments based on maximum segment length.

GeosSeriesAccessor.simplify

Returns a simplified version of an input geometry using the Douglas-Peucker algorithm.

GeosSeriesAccessor.snap

Snaps an input geometry to reference geometry's vertices.

GeosSeriesAccessor.voronoi_polygons

Computes a Voronoi diagram from the vertices of an input geometry.

Linestring Operations#

Methods from Shapely Linestring Operations.

GeosSeriesAccessor.line_interpolate_point

Returns a point interpolated at given distance on a line.

GeosSeriesAccessor.line_locate_point

Returns the distance to the line origin of given point.

GeosSeriesAccessor.line_merge

Returns (Multi)LineStrings formed by combining the lines in a MultiLineString.

GeosSeriesAccessor.shared_paths

Returns the shared paths between geom1 and geom2.

GeosSeriesAccessor.shortest_line

Returns the shortest line between two geometries.

Coordinate Operations#

Methods from Shapely Coordinate Operations.

GeosSeriesAccessor.transform

Returns a copy of a geometry array with a function applied to its coordinates.

GeosSeriesAccessor.count_coordinates

Counts the number of coordinate pairs in a geometry array.

GeosSeriesAccessor.get_coordinates_2d

Gets coordinates from a geometry array as an array of floats.

GeosSeriesAccessor.get_coordinates_3d

Gets coordinates from a geometry array as an array of floats.

GeosSeriesAccessor.set_coordinates

Adapts the coordinates of a geometry array in-place.

STRTree#

Methods from Shapely STRTree.

GeosSeriesAccessor.STRtree

A query-only R-tree spatial index created using the Sort-Tile-Recursive (STR) [1]_ algorithm.

Custom#

Custom methods to add more functionality.

GeosSeriesAccessor.affine

Performs a 2D or 3D affine transformation on all the coordinates.

GeosSeriesAccessor.rotate

Performs a 2D or 3D rotation on all the coordinates.

GeosSeriesAccessor.scale

Performs a 2D or 3D scaling on all the coordinates.

GeosSeriesAccessor.skew

Performs a 2D or 3D skew/shear transformation on all the coordinates.

GeosSeriesAccessor.translate

Performs a 2D or 3D translation on all the coordinates.