Geometry Types
Shiny.Spatial provides a complete set of immutable geometry types following the OGC Simple Features specification. All types are sealed and thread-safe.
Coordinate
Section titled “Coordinate”A 2D coordinate pair representing a point in space. This is a value type (struct).
var coord = new Coordinate(x: -104.99, y: 39.74);
// Aliases for geographic coordinatesdouble lon = coord.Longitude; // same as coord.Xdouble lat = coord.Latitude; // same as coord.Y| Property | Type | Description |
|---|---|---|
X | double | X coordinate (aliased as Longitude) |
Y | double | Y coordinate (aliased as Latitude) |
Supports equality comparison and ToString().
Envelope
Section titled “Envelope”A bounding box (minimum bounding rectangle) defined by min/max coordinates. This is a value type (struct).
var envelope = new Envelope(minX: -109.05, maxX: -102.05, minY: 37.0, maxY: 41.0);
bool inside = envelope.Contains(new Coordinate(-104.99, 39.74)); // truebool overlaps = envelope.Intersects(otherEnvelope);var expanded = envelope.ExpandToInclude(new Coordinate(-110.0, 42.0));| Property | Type | Description |
|---|---|---|
MinX | double | Minimum X value |
MaxX | double | Maximum X value |
MinY | double | Minimum Y value |
MaxY | double | Maximum Y value |
Width | double | MaxX - MinX |
Height | double | MaxY - MinY |
Center | Coordinate | Center point of the envelope |
| Method | Returns | Description |
|---|---|---|
Contains(Coordinate) | bool | Whether the coordinate is inside the envelope |
Intersects(Envelope) | bool | Whether two envelopes overlap |
ExpandToInclude(Coordinate) | Envelope | Returns a new envelope expanded to include the coordinate |
The static Envelope.Empty property returns an empty envelope.
Geometry Base Class
Section titled “Geometry Base Class”All geometry types extend the abstract Geometry class.
| Property/Method | Type | Description |
|---|---|---|
Type | GeometryType | The geometry type enum value |
IsEmpty | bool | Whether the geometry contains no coordinates |
GetEnvelope() | Envelope | Computes the minimum bounding rectangle |
GeometryType Enum
Section titled “GeometryType Enum”public enum GeometryType{ Point = 1, LineString = 2, Polygon = 3, MultiPoint = 4, MultiLineString = 5, MultiPolygon = 6, GeometryCollection = 7}A single coordinate in space.
var point = new Point(-104.99, 39.74);
double x = point.X; // -104.99double y = point.Y; // 39.74var coord = point.Coordinate;| Property | Type | Description |
|---|---|---|
Coordinate | Coordinate | The point’s coordinate |
X | double | X value |
Y | double | Y value |
LineString
Section titled “LineString”An ordered sequence of two or more coordinates forming a line.
var line = new LineString(new[]{ new Coordinate(0, 0), new Coordinate(1, 1), new Coordinate(2, 0)});
bool closed = line.IsClosed; // false (first != last coordinate)| Property | Type | Description |
|---|---|---|
Coordinates | IReadOnlyList<Coordinate> | Ordered list of coordinates |
IsClosed | bool | Whether first and last coordinates are equal |
Polygon
Section titled “Polygon”A closed shape defined by an exterior ring and optional interior rings (holes).
// Simple polygon (no holes)var polygon = new Polygon(new[]{ new Coordinate(-109.05, 37.0), new Coordinate(-102.05, 37.0), new Coordinate(-102.05, 41.0), new Coordinate(-109.05, 41.0), new Coordinate(-109.05, 37.0) // must close the ring});
// Polygon with a holevar withHole = new Polygon( exteriorRing: new[] { new Coordinate(0, 0), new Coordinate(10, 0), new Coordinate(10, 10), new Coordinate(0, 10), new Coordinate(0, 0) }, interiorRings: new[] { new[] { new Coordinate(2, 2), new Coordinate(8, 2), new Coordinate(8, 8), new Coordinate(2, 8), new Coordinate(2, 2) } });| Property | Type | Description |
|---|---|---|
ExteriorRing | IReadOnlyList<Coordinate> | The outer boundary coordinates |
InteriorRings | IReadOnlyList<IReadOnlyList<Coordinate>> | Hole boundaries (may be empty) |
MultiPoint
Section titled “MultiPoint”A collection of Point geometries.
var multiPoint = new MultiPoint(new[]{ new Point(0, 0), new Point(1, 1), new Point(2, 2)});| Property | Type | Description |
|---|---|---|
Points | IReadOnlyList<Point> | The collection of points |
MultiLineString
Section titled “MultiLineString”A collection of LineString geometries.
var multi = new MultiLineString(new[]{ new LineString(new[] { new Coordinate(0, 0), new Coordinate(1, 1) }), new LineString(new[] { new Coordinate(2, 2), new Coordinate(3, 3) })});| Property | Type | Description |
|---|---|---|
LineStrings | IReadOnlyList<LineString> | The collection of line strings |
MultiPolygon
Section titled “MultiPolygon”A collection of Polygon geometries.
var multi = new MultiPolygon(new[] { polygon1, polygon2 });| Property | Type | Description |
|---|---|---|
Polygons | IReadOnlyList<Polygon> | The collection of polygons |
GeometryCollection
Section titled “GeometryCollection”A heterogeneous collection of any geometry types.
var collection = new GeometryCollection(new Geometry[]{ new Point(0, 0), new LineString(new[] { new Coordinate(1, 1), new Coordinate(2, 2) }), polygon});| Property | Type | Description |
|---|---|---|
Geometries | IReadOnlyList<Geometry> | The collection of mixed geometries |