csquares
Encode and decode c-squares, from and to 'simple feature' (sf) or 'spatiotemporal arrays' (stars) objects
Science Score: 39.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
Found .zenodo.json file -
✓DOI references
Found 4 DOI reference(s) in README -
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.5%) to scientific vocabulary
Keywords
spatial
Last synced: 6 months ago
·
JSON representation
Repository
Encode and decode c-squares, from and to 'simple feature' (sf) or 'spatiotemporal arrays' (stars) objects
Basic Info
- Host: GitHub
- Owner: pepijn-devries
- License: gpl-3.0
- Language: R
- Default Branch: main
- Homepage: https://pepijn-devries.github.io/csquares/
- Size: 2.61 MB
Statistics
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
- Releases: 0
Topics
spatial
Created over 1 year ago
· Last pushed 6 months ago
Metadata Files
Readme
Changelog
License
Code of conduct
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
dev = "ggsave",
fig.ext = "png"
)
library(ggplot2)
library(sf)
theme_set(theme_light())
```
# csquares
[](https://github.com/pepijn-devries/csquares/actions/workflows/R-CMD-check.yaml)

[](https://CRAN.R-project.org/package=csquares)
[](https://cran.r-project.org/web/checks/check_results_csquares.html)
[](https://pepijn-devries.r-universe.dev/csquares)
[](https://app.codecov.io/gh/pepijn-devries/csquares)
The Concise Spatial QUery And REpresentation System (c-squares) are identifiers that
correspond with cells in a global grid. The system was developed by
[CSIRO Oceans & Atmosphere](https://en.wikipedia.org/wiki/CSIRO_Oceans_and_Atmosphere) and
divides the globe in rectangles of 10 by 10 degrees (longitude and latitude in
WGS84). It is a hierarchical system, meaning that higher resolutions are also supported,
as long as its cell size is a tenfold of 1 or 5 degrees (i.e., cells can have the following
sizes in degrees: 10, 5, 1, 0.5, 0.1, etc.).
The c-squares format is a well defined exchange format for spatial raster data, it allows
for light-weight text querying / aggregation and expansion to different resolutions. The
csquare R package facilitates the translation of c-square code into spatial information
([sf](https://r-spatial.github.io/sf/) and [stars](https://r-spatial.github.io/stars/))
and vice versa.
For more technical information on c-squares, please consult the
[Wikipedia page](https://en.wikipedia.org/wiki/C-squares) or the
[CSIRO c-squares page](https://www.cmar.csiro.au/csquares/).
## Installation
> Get CRAN version
```{r eval=FALSE}
install.packages("csquares")
```
> Get development version from r-universe
```{r eval=FALSE}
install.packages("csquares", repos = c("https://pepijn-devries.r-universe.dev", "https://cloud.r-project.org"))
```
## Example
The example below is based on killer whale realm data extracted from the publication by
[Costello et al. (2017)](#references).
The `orca` data set itself is *not* provided as a [simple features](https://r-spatial.github.io/sf/)
object, which is commonly used in R for spatial analyses. Instead, spatial information is encoded in
the c-squares format. The example below shows how these codes can be decoded in a spatially explicit
format which can be used for subsequent analyses.
```{r orca, message=FALSE}
library(csquares)
library(sf)
library(ggplot2)
## Convert the data.frame into a csquares object
orca_csq <- as_csquares(orca, csquares = "csquares")
## Convert the csquares object into a simple features object
## and transform to Robinson's projection
orca_sf <-
orca_csq |>
st_as_sf() |>
st_transform(crs = "+proj=robin +lon_0=0 +x_0=0 +y_0=0")
## Make a plot of the spatial data
ggplot(orca_sf) +
geom_sf(aes(fill = orcinus_orca)) +
coord_sf(expand = FALSE)
```
The example above uses existing data with specified c-square codes. You can also
create a raster with c-square codes from scratch. The example below shows how to
create a 0.1 x 0.1 degrees raster for a specific bounding box.
```{r raster}
st_bbox(c(xmin = 5.0, xmax = 5.5, ymin = 52.5, ymax = 53), crs = 4326) |>
new_csquares(resolution = 0.1)
```
## References
*
*
* Costello, M.J. (2017); University of Auckland
Licence [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
* Costello M.J., Tsai P., Wong P.S., Cheung A.K.L, Basher Z. & Chaudhary C. (2017);
"Marine biogeographic realms and species endemicity" Nature Communications 8, 1057
Owner
- Login: pepijn-devries
- Kind: user
- Twitter: pepijn_devries
- Repositories: 3
- Profile: https://github.com/pepijn-devries
GitHub Events
Total
- Watch event: 2
- Push event: 1
- Pull request event: 2
Last Year
- Watch event: 2
- Push event: 1
- Pull request event: 2
Committers
Last synced: 6 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| pepijn-devries | p****s@w****l | 22 |
| pepijn-devries | p****s | 17 |
Committer Domains (Top 20 + Academic)
wur.nl: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 5
- Total pull requests: 55
- Average time to close issues: 8 days
- Average time to close pull requests: 6 minutes
- Total issue authors: 1
- Total pull request authors: 1
- Average comments per issue: 1.0
- Average comments per pull request: 0.09
- Merged pull requests: 44
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: less than a minute
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 1.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- pepijn-devries (5)
Pull Request Authors
- pepijn-devries (55)
Top Labels
Issue Labels
todo (5)
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 116 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 5
- Total maintainers: 1
cran.r-project.org: csquares
Concise Spatial Query and Representation System (c-Squares)
- Homepage: https://pepijn-devries.github.io/csquares/
- Documentation: http://cran.r-project.org/web/packages/csquares/csquares.pdf
- License: GPL (≥ 3)
-
Latest release: 0.1.0
published over 1 year ago
Rankings
Dependent packages count: 28.7%
Dependent repos count: 35.3%
Average: 50.2%
Downloads: 86.5%
Maintainers (1)
Last synced:
6 months ago
Dependencies
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v4 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.5.0 composite
- actions/checkout v4 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION
cran
- R >= 4.1.0 depends
- dplyr * imports
- purrr * imports
- rlang * imports
- sf * imports
- stars * imports
- stringr * imports
- tidyr * imports
- ggplot2 * suggests