polygonize: Raster to vector (polygon) conversion.

Description Usage Arguments Details Value Note Author(s) Examples

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

1
polygonize(obj, fname, engine = c("native", "sp", "sf"), verbose = NA, ...)

Arguments

obj

Object of class ursaRaster.

fname

Missing or character. If specified, then ESRI Shapefile is created. Default is missing.

engine

Character keyword from list c("native","sp","sf"). Define package with tools for creating spatial data. If engine="sp", then functions from package sp are used. If engine="sf", then functions from package sf are used. If engine="native", then apprpopriate package is used based on loaded namespaces before.

verbose

Logical. If TRUE then convertion is attended by progress bar. Default is NA; it means TRUE for engine="sp" and FALSE for engine="sp".

...

Additional arguments, which are passed to internal function for writting ESRI Shapefile.

compress

Logical. Should output ESRI Shapefile files be compressed by zip? Default is FALSE.

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 [email protected]

Examples

1
2
3
4
5
6
7
8
9
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))

nplatonov/ursa documentation built on Oct. 21, 2018, 5:24 p.m.