vector_to_overlay {terrainr} | R Documentation |
Turn spatial vector data into an image overlay
Description
This function allows users to quickly transform any vector data into an image overlay, which may then be imported as a texture into Unity.
Usage
vector_to_overlay(
vector_data,
reference_raster,
output_file = NULL,
transparent = "#ffffff",
...,
error_crs = NULL
)
Arguments
vector_data |
The spatial vector data set to be transformed into an
overlay image. Users may provide either an |
reference_raster |
The raster file to produce an overlay for. The output overlay will have the same extent and resolution as the input raster. Users may provide either a Raster* object or a length 1 character vector containing a path to a file readable by terra::rast. |
output_file |
The path to save the image overlay to. If |
transparent |
The hex code for a color to be made transparent in the
final image. Set to |
... |
Arguments passed to |
error_crs |
Logical: Should this function error if |
Value
output_file
, invisibly.
See Also
Other data manipulation functions:
combine_overlays()
,
georeference_overlay()
,
merge_rasters()
,
raster_to_raw_tiles()
Other overlay creation functions:
combine_overlays()
,
georeference_overlay()
Other visualization functions:
combine_overlays()
,
geom_spatial_rgb()
,
raster_to_raw_tiles()
Examples
## Not run:
# Generate points to download raster tiles for
set.seed(123)
simulated_data <- data.frame(
id = seq(1, 100, 1),
lat = runif(100, 44.1114, 44.1123),
lng = runif(100, -73.92273, -73.92147)
)
# Create an sf object from our original simulated data
simulated_data_sf <- sf::st_as_sf(simulated_data, coords = c("lng", "lat"))
sf::st_crs(simulated_data_sf) <- sf::st_crs(4326)
# Download data!
downloaded_tiles <- get_tiles(simulated_data_sf, tempfile())
merged_file <- merge_rasters(
downloaded_tiles[[1]],
tempfile(fileext = ".tif")
)
# Create an overlay image
vector_to_overlay(simulated_data_sf, merged_file[[1]], na.rm = TRUE)
## End(Not run)