Related Work

Upon learning of the GEOS Geometry work in GeoDjango in May, 2007, Sean Gillies began implementation of PCL's ctypes interface to GEOS, called ​ShapeLy. ShapeLy is still evolving, e.g., it lacks support for the full GEOS API, mutable geometries, and fully-functional constructors for Polygons and GeometryCollections. However, the PCL team is implementing exciting features including a geometry interface (similar to NumPy's ​array interface) and excellent GeoJSON support.

LineString

LineString objects initialize on a given sequence. For example, the constructor may take lists, tuples, ​NumPy arrays of X,Y[,Z] pairs, or Point objects. If Point objects are used, ownership of the points is not transferred to the LineString object. Examples:

The srid keyword may be used to set the spatial reference system identifier number for the geometry. This will be used to conduct any needed transformations for spatial lookups and geographic model creation. It should be noted that fromstr is a shortcut to the constructor for the base GEOSGeometry object.

Output Properties

wkt

Returns the Well-Known Text of the geometry (an OGC standard).

hex

Returns the HEXEWKB PostGIS canonical representation of the geometry. This representation is specific to PostGIS, and is not a standard.

kml

Returns a ​KML (Keyhole Markup Language) representation of the geometry. Should only be used for geometries with an SRID of 4326 (WGS84), but this restriction is not enforced.

Spatial Predicate Properties

empty

Returns whether or not the set of points in the geometry is empty.

valid

Returns a boolean indicating whether the geometry is valid.

simple

A Geometry is simple if and only if the only self-intersections are at boundary points. For example, a LineString object is not simple if it intersects itself (like the one pictured above). Thus, LinearRing and Polygon objects are always simple because they do not intersect themselves.

ring

Returns a boolean indicating whether the geometry is a LinearRing.

hasz

Returns a boolean indicating whether the geometry is three-dimensional.

Spatial Predicate Methods

All of the following spatial predicate methods take another GEOS Geometry instance as an argument (referred to below as other).