| Title: | A Flexible Geometry and Topology Model for Spatial Data in R |
|---|---|
| Description: | A flexible geometry data model for R. |
| Authors: | Michael D. Sumner |
| Maintainer: | Michael D. Sumner <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-10-15 00:49:03 UTC |
| Source: | https://github.com/hypertidy/gris |
The gris package provides a relational table model for spatial vector data in R. Spatial vector data are topology-based discrete spatial units such as areas (including polygons), lines and points.
These kinds of data are defined in many different ways in various R packages, but the sp package has provided the most comprehensive and standard model to match the traditional GIS layer forms.
provide a clear decoupling of topology from geometry (see section "Gris topology" below)
transcend the X/Y-only limitation for vertex attributes
allow multiple topological types in individual layers (i.e. Manifold or MapInfo drawings)
provide a flexible basis for conversion between other formats and domain-specific structures
gris.Spatial |
create from Spatial*DataFrame |
grisFromRasterGeom |
create from geom format |
grisFromFortify |
create from fortify format |
as.gris.triangulation |
create from triangulation
|
plot.gris |
plot a gris object as polypath, lines, points, or triangles |
plot3d.gris |
plot a gris object in 3d |
[.gris |
extract a subset of a gris object |
pointInTriangle |
identify which triangle points fall in |
as.SpatialPolygonsDataFrame.gris |
coerce to SpatialPolygonsDataFrame, SpatialLinesDataFrame, SpatialPointsDataFrame, SpatialMultiPointsDataFrame |
triangulate.gris |
add triangle primitives to a gris object |
brick2col |
create hex value colours from an RGB RasterBrick
|
Topology defines the way that space is filled by 0D (points), 1D (lines), 2D (areas - or polygons) objects. (Higher dimensional topologies are possible but not explored yet.)
Geometry defines an actual instantiation of an object in a given coordinate system.
Examples of the difference are
polygons defining continental outlines on the Earth, these shapes are 2D topologically, but geometrically can be plotted in the plane (in long-lat, or projected coordinates) or "draped" around a curve, such as the Earth as a globe or across a topographic landscape
lines defining animal tracks in space time, these 1D shapes can have geometric vertex attributes such as X, Y, Z, time, temperature, etc.
Topology dimension may be 0D, 1D, 2D, or higher and geometry dimension is not necessarily coupled to this, or restricted to 2D.
Note that certain degeneracies are possible and may be important. A time series of point estimates in space may not have any sensible geometric values at all, but the topological description provided by that time series is a real structure.
as.gris
## S3 method for class 'triangulation' as.gris(x, ...)## S3 method for class 'triangulation' as.gris(x, ...)
x |
triangulation (package RTriangle) |
type |
mesh, triangle polygons, or triangle edges |
Return a list of Polygon, Line or matrix from gris
Spatial classes are defined in the sp package.
as.SpatialPolygonsDataFrame(x, ...) ## S3 method for class 'gris' as.SpatialPolygonsDataFrame(x, ...)as.SpatialPolygonsDataFrame(x, ...) ## S3 method for class 'gris' as.SpatialPolygonsDataFrame(x, ...)
x |
gris object |
... |
ignored |
type |
return type: pp-oly, l-ine, p-oints |
x |
gris object |
Title
brick2col(x)brick2col(x)
x |
RasterBrick |
hex colour character vector
Transform to geocentric coordinates.
geocentric(x, crs = "+proj=geocent +ellps=WGS84")geocentric(x, crs = "+proj=geocent +ellps=WGS84")
x |
table of long, lat, and optionally "height" |
crs |
|
exag |
exaggeration to apply to height values (added to radius) |
tibble
convert from spbabel sptable to gris
grasp(dat1, map1)grasp(dat1, map1)
gris
gris(x, ...) ## S3 method for class 'gris' x[i, j, drop = FALSE] ## S3 method for class 'gris' print(x, ..., n = NULL, width = NULL) ## S3 method for class 'gris' plot(x, y, triangles = FALSE, ...) as.gris(x, ...)gris(x, ...) ## S3 method for class 'gris' x[i, j, drop = FALSE] ## S3 method for class 'gris' print(x, ..., n = NULL, width = NULL) ## S3 method for class 'gris' plot(x, y, triangles = FALSE, ...) as.gris(x, ...)
x |
Spatial* object |
... |
unused |
i |
indices for extract |
j |
indices for extract |
drop |
ignored |
n |
n |
width |
width |
y |
y |
gris
gris implements these base methods:
Plots the object according to its topology type, or by a chosen type. This
method follows base plotting with types "p" points, "l" lines, and adds "pp" for polygons
Prints the object and vertices tables with a summary of the topology linkages
[Subset as an object table on attributes, propagates down through the geometry links to return a subsetted gris object
All availables Spatial*DataFrame types are supported, and are interpreted via the Branch model.
The gris function can ingest SpatialPolygonsDataFrame, SpatialLinesDataFrame, SpatialPointsDataFrame, and SpatialMultiPointsDataFrame objects.
## S3 method for class 'Spatial' gris(x, ...)## S3 method for class 'Spatial' gris(x, ...)
x |
Spatial* object |
... |
not used |
See vignette("branch-vs-primitives")
gris
Not yet implemented
grisFromFortify(x)grisFromFortify(x)
x |
gris
## Not run: data(cmu) sp <- as.SpatialPolygonsDataFrame(cmu) gm <- raster::geom(sp) ## End(Not run)## Not run: data(cmu) sp <- as.SpatialPolygonsDataFrame(cmu) gm <- raster::geom(sp) ## End(Not run)
Not yet implemented
grisFromRasterGeom(x)grisFromRasterGeom(x)
x |
gris
Point in triangle test.
pointInTriangle(x, pt) pointBary(x, pt)pointInTriangle(x, pt) pointBary(x, pt)
x |
gris object with triangulation |
pt |
matrix of xy coordinates |
for PointInTriangle, the index of triangle for each point, in vertex_ form for PointBary, the table of barycentric coordinates and vertex_ index
Template triangle 3d object
t3dt3d
see rgl tetrahedron3d
Add triangle primitives
triangulate(x, ...)triangulate(x, ...)
x |
gris object |
... |
passed on to |
only a has been extensively explored, this is the minimum triangle area in the units of the coordinates
## Not run: library(gris) library(maptools) data(wrld_simpl) gall <- gris(wrld_simpl) g <- gall[gall$o$NAME %in% c("Australia", "New Zealand"), ] g$v <- g$v %>% mutate(x = ifelse(x < 0, x + 360, x)) gT <- gris::triangulate(g) plot(g) plot(gT, triangles = TRUE, add = TRUE) ## End(Not run)## Not run: library(gris) library(maptools) data(wrld_simpl) gall <- gris(wrld_simpl) g <- gall[gall$o$NAME %in% c("Australia", "New Zealand"), ] g$v <- g$v %>% mutate(x = ifelse(x < 0, x + 360, x)) gT <- gris::triangulate(g) plot(g) plot(gT, triangles = TRUE, add = TRUE) ## End(Not run)