simplefeatures

module
v0.59.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: MIT

README

Simple Features

Build Status Go Report Card Coverage Status

Simple Features is a 2D geometry library that provides Go types that model geometries, as well as algorithms that operate on them.

It's a pure Go Implementation of the OpenGIS Consortium's Simple Feature Access Specification (which can be found here). This is the same specification that GEOS, JTS, and PostGIS implement, so the Simple Features API will be familiar to developers who have used those libraries before.

Table of Contents:

Native Go Packages

The Simple Features library contains several packages that are implemented purely in Go, and do not require CGO to use. These are geom, carto, and rtree.

Geom

Package geom provides types (Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, GeometryCollection) representing each geometry, as well as algorithms that operate with/on them.

The following operations are supported:

  • Serialisation: WKT, WKB, GeoJSON, TWKB.
  • Overlay operations: union, intersection, difference, symmetric difference, unary union.
  • Relate operations: DE-9IM matrix, equals, intersects, disjoint, contains, covered by, covers, overlaps, touches, within, crosses.
  • Measurements: area, length, distance.
  • Analysis: centroid, convex hull, envelope, point on surface, boundary, minimum area bounding rectangle, minimum width bounding rectangle.
  • Transformations: simplify, densify, snap to grid, reverse, force clockwise, force counter-clockwise, affine transformation.
  • Buffer: buffer with configurable end cap styles, join styles, and single-sided mode.
  • Prepared geometries: preprocess a geometry for efficient repeated spatial predicate evaluation.
  • Comparison: exact equals.
  • Linear Interpolation: interpolate point, interpolate evenly spaced points.
  • Properties: is simple, is empty, dimension, is clockwise, is counter-clockwise, validate.
  • Envelope operations: intersects, contains, covers, distance, expand to include, center, width, height, area, bounding diagonal.

The overlay, relate, buffer, and prepared geometry operations are powered by a Go port of JTS. This means that it's using robust and battle tested algorithms that are common to JTS and its derivatives (such as GEOS).

Carto

Package carto provides cartographic map projections and related functionality. It can be used as a lite replacement for PROJ for simple cartographic projections.

The following projections are supported:

  • Conic: Lambert conformal conic, Albers equal area conic, equidistant conic.
  • Cylindrical: equirectangular, web mercator, Lambert cylindrical equal area.
  • Azimuthal: orthographic, azimuthal equidistant.
  • Pseudocylindrical: sinusoidal.
  • UTM: All 60 UTM projections.
R-Tree

Package rtree provides an in-memory R-Tree data structure, which can be used for fast and efficient spatial searches.

C-Wrapper Packages

The Simple Features library also contains several packages that depend on C libraries (via CGO). They are segregated into separate Go packages so users who don't need that functionality aren't required to install the relevant C dependencies.

GEOS

Package geos is a thin CGO wrapper around the GEOS library. It provides access to GEOS functionality that has not yet been implemented in the geom package natively in Go.

To install the GEOS C library:

# Debian/Ubuntu
apt-get install libgeos-dev

# Alpine
apk add geos-dev

# macOS
brew install geos
PROJ

Package proj is a thin CGO wrapper around the PROJ library. It provides an exhaustive set of cartographic projections and coordinate transformations.

To install the PROJ C library:

# Debian/Ubuntu
apt-get install libproj-dev

# Alpine
apk add proj-dev

# macOS
brew install proj

Directories

Path Synopsis
Package carto provides cartography functionality for working with and making maps.
Package carto provides cartography functionality for working with and making maps.
Package geom implements the OpenGIS Simple Feature Access specification.
Package geom implements the OpenGIS Simple Feature Access specification.
Package geos provides a cgo wrapper around the GEOS (Geometry Engine, Open Source) library.
Package geos provides a cgo wrapper around the GEOS (Geometry Engine, Open Source) library.
internal
benchmarkreport command
cartodemo/rasterize
Package rasterize rasterizes simplefeatures geometries to raster images.
Package rasterize rasterizes simplefeatures geometries to raster images.
cmprefimpl/scraper command
scraper extracts string literals from the simplefeatures codebase and writes them to a file for use by the cmprefimpl tests.
scraper extracts string literals from the simplefeatures codebase and writes them to a file for use by the cmprefimpl tests.
jtsport/java
Package java provides utilities for transliterating Java code to Go.
Package java provides utilities for transliterating Java code to Go.
jtsport/junit
Package junit provides JUnit-style assertion helpers for ported tests.
Package junit provides JUnit-style assertion helpers for ported tests.
test
Package test provides test helpers.
Package test provides test helpers.
Package rtree implements an in-memory r-tree data structure.
Package rtree implements an in-memory r-tree data structure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL