polygonize {ursa} | R Documentation |
Raster to vector (polygon) conversion.
Description
Representing each raster cell as a polygon. In comparison to common GIS raster to vector conversion, where neighbor cells with the same value are combined to the single polygon, the number of output polygons is equal to number of non-NA
values.
Usage
polygonize(obj, fname, engine = c("native", "sp", "sf"), verbose = NA, ...)
Arguments
obj |
Object of class |
fname |
Missing or character. If specified, then ESRI Shapefile is created. Default is missing. |
engine |
Character keyword from list |
verbose |
Logical. If |
... |
Additional arguments, which are passed to internal function for writing ESRI Shapefile.
|
Details
Some GIS software (e.g., QGIS) has broad tools for display vector data. Excepting choroplets, it is assumed that visualization of each cell separately is more attractive than displaying of polygons with different forms, which are produced, for example, by GDAL convertion utillity gdal_polygonize.py.
Value
If missing fname
and tools from sp then object of class "SpatialPolygonsDataFrame" (package sp).
If missing fname
and tools from sf then object of class "sf" with geometry of class "sfc_POLYGON" (package sf).
If fname
is specified, then NULL
.
Note
Implementation is very slow even for moderate image size. Use progress bar (verbose=TRUE
) to control this process.
Author(s)
Nikita Platonov platonov@sevin.ru
Examples
session_grid(NULL)
a <- ursa_dummy(mul=1/16)
a <- a[a>100]
print(a)
print(band_mean(a))
b2 <- polygonize(a,engine="sp") ## try 'engine="sf"'
print(colMeans(spatial_data(b2),na.rm=TRUE))
print(ursa_bbox(a))
print(spatial_bbox(b2))