Skip to contents

Convert a raster to polygon, remove raster background from vector (white for image, FALSE for mask), aggregate single polygons and set vector values as a single id.

Usage

raster_to_vector(raster, id = "undefined", mask_thr = 255, f_plot = FALSE)

Arguments

raster

A SpatRaster image or mask

id

A string or number defining a common factor for all generated polygons

mask_thr

A number or boolean defining a background value to remove

f_plot

A boolean whether to plot the vectorisation result

Value

A SpatVector

Examples

# Load station
stn <- get_metadata_frost(stationid = 18700)

# Construct box with 200 m radius to extract WMS tile
box <- make_bbox(stn, dx = 200)

# Load a tile
building  <- get_tile_wms(box, layer = "bygning", px = 400)

# Convert raster tile to vector landcover
v_building <- raster_to_vector(building, id = "building", mask_thr = 255)