largest_polygons: Filter the Largest Polygon of each polygon slot of a...

Description Usage Arguments Value See Also Examples

View source: R/largest_polygons.R

Description

Filter the Largest Polygon of each polygon slot of a SpatialPolygon* object

Usage

1

Arguments

sppoly

SpatialPolygon* object as defined in package sp.

subset

a subsetting condition

Value

An object of the same class as sppoly where each slot of the polygons element is made on one single Polygon object that is the largest Polygon is the input sppoly.

See Also

rm_largest_polygons

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(sf)
# working on the provinces polygons of Vietnam:
vn_prov <- gadmVN::gadm()
vn_prov <- sf::as_Spatial(vn_prov)
vn_prov2 <- largest_polygons(vn_prov)
sp::plot(vn_prov)
sp::plot(vn_prov2)
# same with the country level:
vn <- gadmVN::gadm(level = "country")
vn <- sf::as_Spatial(vn)
vn2 <- largest_polygons(vn)
rgeos::gEnvelope(vn)
# extracting the largest polygon only for Da Nang:
vn_prov3 <- largest_polygons(vn_prov, province == "Da Nang")
sp::plot(vn_prov3)
# extracting the largest polygon only for Da Nang and Khanh Hoa:
vn_prov4 <- largest_polygons(vn_prov, province %in% c("Da Nang", "Khanh Hoa"))
sp::plot(vn_prov4)

choisy/sptools documentation built on Aug. 22, 2019, 12:57 p.m.