geometr

Generate and modify interoperable geometric shapes

https://github.com/ehrmanns/geometr

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (19.1%) to scientific vocabulary

Keywords

geometric-shapes getters interoperability setters spatial-data
Last synced: 6 months ago · JSON representation

Repository

Generate and modify interoperable geometric shapes

Basic Info
Statistics
  • Stars: 14
  • Watchers: 2
  • Forks: 1
  • Open Issues: 2
  • Releases: 3
Topics
geometric-shapes getters interoperability setters spatial-data
Created about 7 years ago · Last pushed about 2 years ago
Metadata Files
Readme Changelog

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

# calling any function from geometr for the first time creates an annoying
# message about spatstat, which I can remove by calling it here without
# including this chunk in the Rmd
library(sf)
library(geometr)
nc_sf <- st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)
geomio::getFeatures(nc_sf)
```
# geometr 


[![R-CMD-check](https://github.com/EhrmannS/geometr/workflows/R-CMD-check/badge.svg)](https://github.com/EhrmannS/geometr/actions)
[![Coverage
Status](https://codecov.io/gh/EhrmannS/geometr/branch/master/graph/badge.svg)](https://codecov.io/github/EhrmannS/geometr?branch=master)
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/geometr)](https://cran.r-project.org/package=geometr)
[![](http://cranlogs.r-pkg.org/badges/grand-total/geometr)](https://cran.r-project.org/package=geometr)




## Overview

The `geometr` package provides tools that generate and process easily accessible and tidy geometric shapes (of class `geom`). Moreover, it aims to improve interoperability of spatial and other geometric classes. Spatial
classes are typically a collection of geometric shapes (or their vertices) that are accompanied by various metadata (such as attributes and a coordinate reference system). Most spatial classes are thus conceptually quite similar, yet a common standard lacks for accessing features, vertices or the metadata. `geometr` fills this gap by
providing tools that

  - produce an identical output for the same metadata of different classes (via so-called getters) and
  - use an identical input to write to various classes that originally require different input (via so-called setters).

## Installation

1) Install the official version from CRAN:

```{r, eval=FALSE}
install.packages("geometr")
```

or the latest development version from github:

```{r, eval=FALSE}
devtools::install_github("EhrmannS/geometr")
```

2) The [vignette](https://ehrmanns.github.io/geometr/articles/geometr.html) gives an in depth introduction, explains the take on interoperability and discusses the spatial class `geom` that comes with `geometr`.

3) Have fun being a [geometer](https://en.wikipedia.org/wiki/List_of_geometers)\!

## Examples

Create a `geom`

```{r}
library(geometr)

# ... from other classes
library(sf)
nc_sf <- st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)
nc_geom <- geomio::as_geometr(x = nc_sf)
```

Metadata of different classes can be extracted in interoperable quality (i.e. the same metadata in different objects/classes have the same names and the same arrangement).

```{r}
geomio::getExtent(x = nc_geom)

geomio::getFeatures(x = nc_geom)
```

`geometr` only knows the feature types `point`, `line`, `polygon` and `grid` (a systematic lattice of points). 
In contrast to the simple features standard, there are no  *MULTI\** features. 
The way simple features have been implemented in R has the consequence that certain information can only be stored in a rather inefficient and cumbersome way. 
Think of a set of polygons that has individual attributes at the `POLYGON` level, but also attributes at the group (`MULTIPOLYGON`) level, i.e., where all polygons of that group have the same value of the respective attributes.
It is impossible to store this information in a single `sf` object, other than in a `POLYGON` that contains the respective attributes as duplicates (which may be very inefficient in large objects).

The backbone of a `geom` are three tables, one for points, one for features and one for groups of features, the latter two of which can be provided with ancillary information (attributes).
Each point is stored with a feature ID (`fid`) that relates it to a feature (and its attributes) and each feature is stored with a group ID (`gid`) that relates it to a group (and its attributes).
Eventually this results in a tidier data-structure with easier access than `sp` or `sf` objects and with higher versatility.

```{r}
# when using the group = TRUE argument, the attributes of MULTI*-feature are
# stored in the group attribute table of a geom
nc_geom <- geomio::as_geometr(x = nc_sf, group = TRUE)
currituck <- geo_filter(obj = nc_geom, gid == 4)

geomio::getFeatures(x = currituck)
geomio::getGroups(x = currituck)

# and new attributes can be set easily, 
newTable <- data.frame(fid = c(1:108), 
                       attrib = rnorm(108))
(nc_geom <- geomio::setFeatures(x = nc_geom, table = newTable))
```

Moreover, a `geom` also allows to store raster information in the same data format.
A raster is a systematic lattice of points/pixels with one or more layers, where each pixel exists in each layer, possibly with different values, i.e., from different attributes.
The raster attribute table (RAT) is basically already the groups attribute table of a `geom`, where a group of pixels that have the same value are associated to attributes this class has in common.
In this case, however, the features (single pixels) don't have to be associated to a group ID, as their feature values are at the same time the group values.

```{r}
str(geoms$polygon, max.level = 2)

str(geoms$grid, max.level = 2)
```


`geometr` comes with the `visualise` function, which makes nice-looking diagnostic spatial plots, that show explicit values whenever possible.
For example, it does not create artificial (\"nice\") bins for the x and y axis or the values values shown in the plot, but provides the range of values explicitly.
Moreover, you can easily set plot titles without much effort.

```{r, fig.height=3}
geo_vis(`North Carolina` = nc_geom)
```

You can use quick options to scale plot parameters to the attributes of the `geom` to modify which aspects of an object should be shown in the plot, for example when scaling `fillcol` to `NWBIR74`.

```{r, fig.height=3}
myAttr <- "NWBIR74"
geo_vis(!!paste0("NC - ", myAttr) := nc_geom, fillcol = !!myAttr)
```

The `@window` slot of a modified `geom` is by default automatically updated.

```{r, fig.height=3.5}
geo_vis(`Currituck` = currituck, linecol = "fid")
```

Finally, cast a `geom` to another type simply by providing it in `anchor` of the respective type

```{r, fig.height=3.5}
boundPoints <- geo_point(crds = geomio::getPoints(currituck))
geo_vis(`Currituck - boundary vertices`= boundPoints, linecol = "fid")
```

Owner

  • Name: Steffen Ehrmann
  • Login: EhrmannS
  • Kind: user
  • Location: Leipzig, Germany
  • Company: Center for Integrative Biodiversity Research (iDiv)

Building global time-series of various land-use variables and trying to promote interoperability of spatial classes.

GitHub Events

Total
Last Year

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 1,092
  • Total Committers: 4
  • Avg Commits per committer: 273.0
  • Development Distribution Score (DDS): 0.382
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Steffen Ehrmann s****e@f****e 675
Steffen Ehrmann s****n@i****e 412
Steffen Ehrmann s****n@p****e 4
Jim Hester j****r@g****m 1
Committer Domains (Top 20 + Academic)

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 6
  • Total maintainers: 1
cran.r-project.org: geometr

Generate and Modify Interoperable Geometric Shapes

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Stargazers count: 15.1%
Forks count: 21.9%
Average: 25.6%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Last synced: about 1 year ago

Dependencies

DESCRIPTION cran
  • R >= 2.10 depends
  • checkmate * imports
  • crayon * imports
  • deldir * imports
  • dplyr * imports
  • grDevices * imports
  • grid * imports
  • magrittr * imports
  • methods * imports
  • purrr * imports
  • raster * imports
  • rgdal * imports
  • rlang * imports
  • sf * imports
  • sp * imports
  • terra * imports
  • tibble * imports
  • bookdown * suggests
  • covr * suggests
  • knitr * suggests
  • rmarkdown * suggests
  • testthat * suggests
.github/workflows/check-standard-spatial.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/upload-artifact main composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
.github/workflows/pkgdown.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
.github/workflows/test-coverage.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite