R/crop_aggr_utm.R
crop_aggr_utm.Rd
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 )
r | The |
---|---|
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 |
proj_utm | A Universal Transverse Mercator projection string of class |
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. |
Edward Lavender
#### 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 preserveddat_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...#> Defining plot properties... #> Producing plot...