polygonize | R Documentation |
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.
polygonize(obj, fname, engine = c("native", "sf"), verbose = NA, ...)
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.
|
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.
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
.
Implementation is very slow even for moderate image size. Use progress bar (verbose=TRUE
) to control this process.
Nikita Platonov platonov@sevin.ru
session_grid(NULL)
a <- ursa_dummy(mul=1/16)
a <- a[a>100]
print(a)
print(band_mean(a))
b2 <- polygonize(a,engine=ifelse(requireNamespace("sp"),"sp","sf"))
print(class(b2))
print(colMeans(spatial_data(b2),na.rm=TRUE))
str(e1 <- spatial_bbox(a))
str(e2 <- spatial_bbox(b2))
print(as.numeric(e1))
print(as.numeric(e2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.