适用于现代空间数据的高性能点阵转换 ▦
Fast polygon-to-raster conversion, burn polygon shapes and/or values
into pixels.
fasterize is a high-performance replacement for the rasterize()
function in the raster
package.
Functionality is currently limited to rasterizing polygons in sf-type data frames.
Install the current version of fasterize from CRAN:
install.packages('fasterize')Install the development version of fasterize with devtools:
devtools::install_github("hypertidy/fasterize")fasterize uses Rcpp and thus requires a compile toolchain to install from source. Testing (and for normal use of sf objects) requires sf, which requires GDAL, GEOS, and PROJ to be installed.
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.
library(raster)
library(fasterize)
library(wk)
library(fasterize)
p123 dialect must be 'OGRSQL' or 'SQLITE', default value '' means 'OGRSQL'
``` r
pols_t$value Unit: milliseconds
#> expr min lq mean median uq max neval cld
#> terrarize 9.464 9.761 11.306 10.022 10.375 82.0 100 a
#> fasterize 0.647 0.684 0.839 0.845 0.971 1.1 100 b
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
if(!dir.exists("Mammals_Terrestrial")) {
download.file(
"https://s3.amazonaws.com/hp3-shapefiles/Mammals_Terrestrial.zip",
destfile = "Mammals_Terrestrial.zip") # 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
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.暂无开放 Issues,或尚未同步最近议题。