fasterize
High performance raster conversion for modern spatial data 🚀🌏▦
Science Score: 36.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
-
○Academic publication links
-
✓Committers with academic emails
1 of 7 committers (14.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.6%) to scientific vocabulary
Keywords
r
raster
rcpp
rcpparmadillo
rstats
sf
spatial
Keywords from Contributors
r-targetopia
reproducibility
targets
wildlife
drake
makefile
ropensci
crypto-currency-exchanges
archiving
dbi
Last synced: 4 months ago
·
JSON representation
Repository
High performance raster conversion for modern spatial data 🚀🌏▦
Basic Info
- Host: GitHub
- Owner: hypertidy
- License: other
- Language: C++
- Default Branch: main
- Homepage: https://hypertidy.github.io/fasterize/
- Size: 1.08 MB
Statistics
- Stars: 185
- Watchers: 9
- Forks: 15
- Open Issues: 28
- Releases: 0
Topics
r
raster
rcpp
rcpparmadillo
rstats
sf
spatial
Created almost 9 years ago
· Last pushed 10 months ago
Metadata Files
Readme
Changelog
Contributing
License
Code of conduct
Codemeta
README.Rmd
---
output:
github_document:
html_preview: FALSE
---
```{r, setup, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
comment = "#>",
tidy = FALSE,
error = FALSE,
fig.width = 7,
fig.height = 4.5,
fig.path = 'vignettes/readme-',
cache=FALSE)
```
# fasterize
Fast polygon-to-raster conversion, burn polygon shapes and/or values into pixels.
[](https://github.com/hypertidy/fasterize/actions/workflows/R-CMD-check.yaml)
[](http://www.repostatus.org/#active)
[](https://badges.mit-license.org/)
[](https://CRAN.R-project.org/package=fasterize)
[](https://www.r-pkg.org/pkg/fasterize)
[](https://app.codecov.io/gh/hypertidy/fasterize)
**fasterize** is a high-performance replacement for the `rasterize()` function
in the [**raster**](https://cran.r-project.org/package=raster) package.
Functionality is currently limited to rasterizing polygons in [**sf**](https://cran.r-project.org/package=sf)-type
data frames.
## Installation
Install the current version of **fasterize** from CRAN:
```{r eval = FALSE}
install.packages('fasterize')
```
Install the development version of **fasterize** with [**devtools**](https://cran.r-project.org/package=devtools):
```{r eval = FALSE}
devtools::install_github("hypertidy/fasterize")
```
**fasterize** uses [**Rcpp**](https://cran.r-project.org/package=Rcpp) and thus requires a compile toolchain to install from source.
Testing (and for normal use of sf objects) requires [**sf**](https://cran.r-project.org/package=sf), which requires GDAL, GEOS, and PROJ to be installed.
## Usage
The main function, `fasterize()`, takes the same inputs as `raster::rasterize()` but currently has fewer options and is
is limited to rasterizing polygons.
A `raster()` and `plot()` methods for rasters are re-exported from the [raster package](https://cran.r-project.org/package=raster).
```{r example-1, message=FALSE}
library(raster)
library(fasterize)
library(wk)
library(fasterize)
p123 <- c(paste0("POLYGON ((-180 -20, -140 55, 10 0, -140 -60, -180 -20),",
"(-150 -20, -100 -10, -110 20, -150 -20))"),
"POLYGON ((-10 0, 140 60, 160 0, 140 -55, -10 0))",
"POLYGON ((-125 0, 0 60, 40 5, 15 -45, -125 0))")
pols <- data.frame(value = seq_along(p123), geometry = wk::as_wkt(p123))
ex <- as.numeric(wk_bbox(pols))[c(1, 3, 2, 4)]
r <- raster::raster(raster::extent(ex), res = 1)
r <- fasterize(pols, r, field = "value", fun="sum")
plot(r)
```
## Performance
Let's compare `fasterize()` to `terra::rasterize()`:
```{r benchmark, cache=TRUE}
pols_t <- terra::vect(p123)
pols_t$value <- 1:3
#pols_r <- as(pols_t, "Spatial")
tr <- terra::rast(r)
bench <- microbenchmark::microbenchmark(
# rasterize = r <- raster::rasterize(pols_r, r, field = "value", fun="sum"),
terrarize = tr <- terra::rasterize(pols_t, tr, field = "value", fun = "sum"),
fasterize = f <- fasterize(pols, r, field = "value", fun="sum"),
unit = "ms"
)
print(bench, digits = 3)
```
How does `fasterize()` do on a large set of polygons? Here I download the IUCN shapefile for the ranges of all terrestrial mammals and generate
a 1/6 degree world map of mammalian biodiversity by rasterizing all the layers.
(this doesn't work anymore because the source data is gone, left as a record 2024-09-25).
```{r download, eval=FALSE, cache=TRUE}
if(!dir.exists("Mammals_Terrestrial")) {
download.file(
"https://s3.amazonaws.com/hp3-shapefiles/Mammals_Terrestrial.zip",
destfile = "Mammals_Terrestrial.zip") # <-- 383 MB
unzip("Mammals_Terrestrial.zip", exdir = ".")
unlink("Mammals_Terrestrial.zip")
}
```
```{r so-damn-fast, cache=FALSE, eval=FALSE}
mammal_shapes <- st_read("Mammals_Terrestrial")
mammal_raster <- raster(mammal_shapes, res = 1/6)
bench2 <- microbenchmark::microbenchmark(
mammals = mammal_raster <- fasterize(mammal_shapes, mammal_raster, fun="sum"),
times=20, unit = "s")
print(bench2, digits=3)
par(mar=c(0,0.5,0,0.5))
plot(mammal_raster, axes=FALSE, box=FALSE)
```
#> Unit: seconds
#> expr min lq mean median uq max neval
#> mammals 0.847 0.857 0.883 0.886 0.894 0.963 20

## About
**fasterize** was developed openly at [EcoHealth Alliance](https://www.ecohealthalliance.org/) under the USAID PREDICT project by Noam Ross. The repository for hosting fasterize was taken over by Michael Sumner in December 2022, and was later migrated from Github 'ecohealthalliance/fasterize' to https://github.com/hypertidy/fasterize in March 2025.
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
[](https://www.ecohealthalliance.org/)
[](https://ohi.vetmed.ucdavis.edu/programs-projects/predict-project)
Owner
- Name: hypertidy
- Login: hypertidy
- Kind: organization
- Location: Hobart, Australia
- Website: https://hypertidy.r-universe.dev/
- Repositories: 59
- Profile: https://github.com/hypertidy
[ ... ]
CodeMeta (codemeta.json)
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "fasterize",
"description": "Provides a drop-in replacement for rasterize() from the 'raster' package that takes 'sf'-type objects, and is much faster. There is support for the main options provided by the rasterize() function, including setting the field used and background value, and options for aggregating multi-layer rasters. Uses the scan line algorithm attributed to Wylie et al. (1967) <doi:10.1145/1465611.1465619>.",
"name": "fasterize: Fast Polygon to Raster Conversion ",
"codeRepository": "https://github.com/hypertidy/fasterize",
"issueTracker": "https://github.com/hypertidy/fasterize/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "1.0.4",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.2.1 (2022-06-23)",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"contributor": [
{
"@type": "Person",
"givenName": "Noam",
"familyName": "Ross",
"email": "ross@ecohealthalliance.org",
"@id": "https://orcid.org/0000-0002-2136-0000"
}
],
"author": [
{
"@type": "Person",
"givenName": "Michael",
"familyName": "Sumner",
"email": "mdsumner@gmail.com",
"@id": "https://orcid.org/0000-0002-2471-7511"
},
{
"@type": "Person",
"givenName": "Jeroen",
"familyName": "Ooms"
},
{
"@type": "Person",
"givenName": "Antoine",
"familyName": "Stevens"
}
],
"copyrightHolder": [
{
"@type": "Organization",
"name": "EcoHealth Alliance"
}
],
"funder": [
{
"@type": "Organization",
"name": "USAID PREDICT"
}
],
"maintainer": [
{
"@type": "Person",
"givenName": "Michael",
"familyName": "Sumner",
"email": "mdsumner@gmail.com",
"@id": "https://orcid.org/0000-0002-2471-7511"
}
],
"softwareSuggestions": [
{
"@type": "SoftwareApplication",
"identifier": "testthat",
"name": "testthat",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=testthat"
},
{
"@type": "SoftwareApplication",
"identifier": "microbenchmark",
"name": "microbenchmark",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=microbenchmark"
},
{
"@type": "SoftwareApplication",
"identifier": "knitr",
"name": "knitr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=knitr"
},
{
"@type": "SoftwareApplication",
"identifier": "rmarkdown",
"name": "rmarkdown",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rmarkdown"
},
{
"@type": "SoftwareApplication",
"identifier": "sf",
"name": "sf",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=sf"
},
{
"@type": "SoftwareApplication",
"identifier": "spelling",
"name": "spelling",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=spelling"
}
],
"softwareRequirements": {
"1": {
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 3.3.0"
},
"2": {
"@type": "SoftwareApplication",
"identifier": "methods",
"name": "methods"
},
"3": {
"@type": "SoftwareApplication",
"identifier": "Rcpp",
"name": "Rcpp",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=Rcpp"
},
"4": {
"@type": "SoftwareApplication",
"identifier": "raster",
"name": "raster",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=raster"
},
"5": {
"@type": "SoftwareApplication",
"identifier": "sp",
"name": "sp",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=sp"
},
"SystemRequirements": "C++11"
},
"fileSize": "19162.002KB"
}
GitHub Events
Total
- Issues event: 2
- Watch event: 2
- Issue comment event: 5
- Push event: 8
Last Year
- Issues event: 2
- Watch event: 2
- Issue comment event: 5
- Push event: 8
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Michael Sumner | m****r@g****m | 40 |
| Noam Ross | n****s@g****m | 32 |
| Noam Ross (the Robot Version) | r****s@e****g | 31 |
| Antoine Stevens | A****s@m****m | 2 |
| Kendon Bell | k****B | 1 |
| Jeroen Ooms | j****s@g****m | 1 |
| Max Czapanskiy | m****p@s****u | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 44
- Total pull requests: 14
- Average time to close issues: over 1 year
- Average time to close pull requests: 4 months
- Total issue authors: 18
- Total pull request authors: 6
- Average comments per issue: 2.36
- Average comments per pull request: 0.93
- Merged pull requests: 10
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 4
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: 36 minutes
- Issue authors: 2
- Pull request authors: 1
- Average comments per issue: 2.25
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- noamross (16)
- mdsumner (11)
- lime-n (1)
- adrfantini (1)
- jldupouey (1)
- mbedward (1)
- fab4ap (1)
- herryATcsiro (1)
- FlukeAndFeather (1)
- ricschuster (1)
- JimShady (1)
- JoshOBrien (1)
- rsbivand (1)
- johnForne (1)
- jeffreyhanson (1)
Pull Request Authors
- mdsumner (9)
- FlukeAndFeather (1)
- JhossePaul (1)
- kendonB (1)
- antoinestevens (1)
- jeroen (1)
Top Labels
Issue Labels
feature (10)
Rcpp (10)
maybe (2)
wip (1)
docs (1)
good first issue (1)
duplicate (1)
high priority (1)
help wanted (1)
Pull Request Labels
wip (1)
Dependencies
DESCRIPTION
cran
- R >= 3.3.0 depends
- Rcpp * imports
- methods * imports
- raster * imports
- sp * imports
- knitr * suggests
- microbenchmark * suggests
- rmarkdown * suggests
- sf * suggests
- testthat * suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc 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.4.1 composite
- actions/checkout v3 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
Dockerfile
docker
- rocker/geospatial devel build