| rasterize_mask_cpp | R Documentation |
Burns all polygon features from a vector source into a new single-band
GeoTIFF raster that is spatially aligned to a reference raster. Pixels
that fall inside at least one polygon are set to 1; all other
pixels are set to 0.
rasterize_mask_cpp(vector_path, ref_raster_path, output_mask_path)
vector_path |
Character string: path to any OGR-readable vector source (shapefile, GeoJSON, GeoPackage, etc.). |
ref_raster_path |
Character string: path to a GDAL-readable raster used as the spatial reference (extent, resolution, CRS). |
output_mask_path |
Character string: file path where the output
|
This function is the low-level C++ entry point. Most users should call
the higher-level create_mask wrapper instead.
Stops with an informative error if the package was built without GDAL support.
Invisibly returns NULL. The side effect is the creation
of the output mask raster at output_mask_path.
create_mask, apply_mask_cpp
if (has_gdal()) {
# Requires GDAL support at build time.
ref <- system.file("extdata", "tiny.tif", package = "xbioclim")
poly <- tempfile(fileext = ".geojson")
mask <- tempfile(fileext = ".tif")
writeLines(
'{"type":"FeatureCollection","features":[{"type":"Feature",
"geometry":{"type":"Polygon","coordinates":[[[0,0],[1,0],[1,1],[0,1],[0,0]]]},
"properties":{}}]}',
poly)
rasterize_mask_cpp(poly, ref, mask)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.