Rasterise land use zones (sf_landuse) with reference to population data (sf_pop), if supplied. Multiple (a list of) output rasters will be generated if land use data for multiple years are present. If the land use data includes unnecessary land use classes, the argument subset and landuse allows the user to first subset the data to polygons defined as 'residential' land use.

rasterise_landuse(
  sf_landuse,
  subset = NULL,
  land_use = NULL,
  year = "year",
  sf_pop = NULL,
  match_landuse_pop = "recent",
  dir_rastertemplate = NULL,
  dir_processing = tempdir(),
  dir_export = tempdir(),
  overwrite = TRUE,
  wopt = list(gdal = c("COMPRESS=LZW")),
  ...
)

Arguments

sf_landuse

sf polygons of the land use zones. Data should be in a projected coordinate reference system.

subset

Named vector containing the residential land use classes of interest to retain in column land_use. Each element is named according to the integer that will be used to represent this class in the output raster. Defaults to NULL (integers will be alphabetically assigned to land use classes).

land_use

character. Specify column name of the land use classes.

year

character. Specify column name for the year within sf_landuse and sf_pop (if provided). Defaults to 'year'. Column data should be numeric.

sf_pop

(optional) sf polygons containing the population census data with column containing the census year. If absent, the output (land use rasters) will not be associated with specific population census year(s).

match_landuse_pop

character. Type of matching between sf_landuse and sf_pop, passed on to match argument in function matchyear(). Either 'exact', 'closest', 'recent' or 'soonest'. Defaults to 'recent', i.e. assumes that land use is pre-planned (and followed by population changes), rather than a result of post-monitoring (e.g. remotely-sensed).

dir_rastertemplate

character. Filepath to the raster used to define the pixel resolution, extent, nrow, ncol of the output raster; object is passed to the 'y' argument in terra::rasterize(). Defaults to the template raster generated by the function rasterise_pop() within dir_processing (see next argument).

dir_processing

character. Directory to get intermediate files generated in previous steps (e.g. rasterised population data). Defaults to tempdir().

dir_export

character. File path to directory to export output raster(s) to. Defaults to tempdir(). Set to NULL if you do not wish to export output for subsequent processing.

overwrite

logical. Argument passed to terra::writeRaster(). Defaults to TRUE.

wopt

list. Argument passed to terra::writeRaster().

...

Other arguments passed to terra::writeRaster().

Value

List of raster files. Zero values are converted to NA. Each raster is also an intermediate file exported to the directory as defined by dir_export(defaults to tempdir()) for further processing.

Details

If population data (sf_pop) is supplied, its raster(s) must have been previously generated in the tempdir() using the function rasterise_pop(). Each year in the population data is matched to a specific year in the land use data (using the helper function matchyear()). Land use raster(s) will then be associated with a specific population census year, and removed if there are no matching population census years. Rasterised land use zones will be masked away (i.e., convert pixels to NA) at areas with no (zero) population data (for the respective matching year).

Examples

if (FALSE) {
data(pop_sgp)
data(landuse_sgp)


# transform to projected crs
pop_sgp <- sf::st_transform(pop_sgp, sf::st_crs(32648))
landuse_sgp <- sf::st_transform(landuse_sgp, sf::st_crs(32648))


# run function
landuse_rasters <- rasterise_landuse(landuse_sgp,
                                     land_use = 'lu_desc',
                                     subset = c('1' = 'RESIDENTIAL',
                                                '2' = 'COMMERCIAL & RESIDENTIAL',
                                                '3' = 'RESIDENTIAL WITH COMMERCIAL AT 1ST STOREY',
                                                '4' = 'RESIDENTIAL / INSTITUTION'),
                                     year = 'year',
                                     sf_pop = pop_sgp,
                                     match_landuse_pop = 'recent')
}