raster_to_raw_tiles: Crop a raster and convert the output tiles into new formats.

Description Usage Arguments Value See Also Examples

View source: R/raster_to_raw_tiles.R

Description

This function crops input raster files into smaller square tiles and then converts them into either .png or .raw files which are ready to be imported into the Unity game engine.

Usage

1
raster_to_raw_tiles(input_file, output_prefix, side_length = 4097, raw = TRUE)

Arguments

input_file

File path to the input TIFF file to convert.

output_prefix

The file path to prefix output tiles with.

side_length

The side length, in pixels, for the .raw tiles.

raw

Logical: Convert the cropped tiles to .raw? When FALSE returns a .png.

Value

Invisibly, a character vector containing the file paths that were written to.

See Also

Other data manipulation functions: combine_overlays(), georeference_overlay(), merge_rasters(), vector_to_overlay()

Other visualization functions: combine_overlays(), geom_spatial_rgb(), vector_to_overlay()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
if (!isTRUE(as.logical(Sys.getenv("CI")))) {

simulated_data <- data.frame(
  id = seq(1, 100, 1),
  lat = runif(100, 44.04905, 44.17609),
  lng = runif(100, -74.01188, -73.83493)
)
simulated_data <- sf::st_as_sf(simulated_data, coords = c("lng", "lat"))
output_files <- get_tiles(simulated_data)
temptiff <- tempfile(fileext = ".tif")
merge_rasters(output_files["elevation"][[1]], temptiff)
raster_to_raw_tiles(temptiff, tempfile())

}

## End(Not run)

terrainr documentation built on Feb. 23, 2021, 9:06 a.m.