The 3d, interactive visualisation of large rasters (e.g. with pretty_scape_3d) can be constrained by memory requirements. Therefore, often, it may be preferable to crop a raster to a smaller area and aggregate the raster (if necessary) to reduce raster size prior to plotting. For meaningful landscape visualisations, it is also helpful to convert rasters, if required, to the Universal Transverse Mercator system, so that x, y and z coordinates are all on the same scale. This function is a wrapper function for crop, aggregate and projectRaster which implements these operations. This facilitates the visualisation of large raster files in chunks via pretty_scape_3d.

crop_aggr_utm(
  r,
  x1,
  x2,
  y1,
  y2,
  aggregate = NULL,
  proj_utm = sp::CRS(paste("+proj=utm +zone=29 +datum=WGS84",
    "+units=m +no_defs +ellps=WGS84 +towgs84=0,0,0")),
  verbose = TRUE
)

Arguments

r

The raster to be processed.

x1

A number which specifies the minimum x value for the raster. The raster will be cropped by this value.

x2

A number which specifies the maximum y value for the raster. The raster will be cropped by this value.

y1

A number which specifies the minimum x value for the raster. The raster will be cropped by this value.

y2

A number which specifies the maximum y value for the raster. The raster will be cropped by this value.

aggregate

(optional) A named list of arguments that is passed to aggregate to aggregate the cropped raster.

proj_utm

A Universal Transverse Mercator projection string of class CRS-class. Zone 29 is the default.

verbose

A logical input which defines whether or not to print messages to the console regarding function progress. This can be helpful because cropping, aggregating and re-projecting large rasters can take some time.

Author

Edward Lavender

Examples

#### Example (1) Crop dat_gebco raster to defined area, aggregate and ensure UTM coordinates for # ... sensible visualisation on the scale of the data: proj_utm <- sp::CRS("+proj=utm +zone=29 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0")
#> Warning: Discarded datum WGS_1984 in CRS definition, #> but +towgs84= values preserved
dat_gebco_processed <- crop_aggr_utm(dat_gebco, -5.5, -5.4, 56.36, 56.44, aggregate = list(fact = 2, fun = max), proj_utm = proj_utm)
#> Defining raster extent... #> Cropping raster... #> Aggregating raster... #> Reprojecting raster to UTM... #> Printing raster dimensions... #> 12, 17, 1 #> Returning raster...
pretty_scape_3d(dat_gebco_processed, aspectmode = "data", stretch = 10)
#> Defining plot properties... #> Producing plot...