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 platonov@sevin.ru

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))

Example output

            name    mean      sd     sum     min     max   n nNA
[1] Wednesday 30 142.906 27.2601 46158.7 100.044 208.099 323 209
[2] Thursday 31  162.447 38.6445 64004.1 100.208 242.141 394 138
[3] Friday 01    157.333 32.2029 69541.0 100.260 233.472 442  90
Wednesday 30  Thursday 31    Friday 01 
    142.9062     162.4470     157.3325 
================================================================================
Wednesday 30  Thursday 31    Friday 01 
    142.9062     162.4470     157.3325 
    xmin     ymin     xmax     ymax 
-3850000 -5350000  3750000  5850000 
attr(,"crs")
[1] "+proj=stere +lat_0=90 +lat_ts=70.0 +lon_0=-45.0 +k=1 +x_0=0.0 +y_0=0.0 +a=6378273.000 +b=6356889.449 +units=m +no_defs"
    xmin     ymin     xmax     ymax 
-3850000 -5350000  3750000  5850000 
attr(,"crs")
[1] "+proj=stere +lat_0=90 +lat_ts=70.0 +lon_0=-45.0 +k=1 +x_0=0.0 +y_0=0.0 +a=6378273.000 +b=6356889.449 +units=m +no_defs"

ursa documentation built on Feb. 26, 2020, 3:01 p.m.