geo_is_missing: Missing, empty, and non-finite geometries

Description Usage Arguments Format Value Examples

View source: R/geo-missing.R

Description

Whereas EMPTY geometries are a concept at the geometry level, missing values are a concept of the in-memory vectors used to store them in R. The geo_is_missing() function can be used to identify these values, similar to is.na(). Missing coordinates (NA or NaN) can be identified using geo_has_missing(), and geo_is_finite() can be used to ensure that all coordinates are finite. Note that geo_xy(NA, NA), wkt("POINT (nan nan)"), and wkt("MULTIPOINT (nan nan)") are all considered empty points, and are therefore non-misssing, contain no missing coordinates, and are finite (use is.na() and/or stringr::str_detect()) if you would like to specifically detect these cases).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19

Arguments

x

A geometry-like object, or one that can be coerced to a geometry-like object using as_geovctr().

Format

An object of class wk_wkt (inherits from wk_vctr) of length 1.

An object of class wk_wkb (inherits from wk_vctr) of length 1.

An object of class NULL of length 0.

An object of class geovctrs_xy (inherits from vctrs_rcrd, vctrs_vctr) of length 1.

An object of class geovctrs_segment (inherits from vctrs_rcrd, vctrs_vctr) of length 1.

An object of class geovctrs_rect (inherits from vctrs_rcrd, vctrs_vctr) of length 1.

Value

A logical vector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
geo_is_missing(NA_wkt_)
geo_has_missing(NA_wkt_)
geo_is_finite(NA_wkt_)
geo_is_empty(NA_wkt_)

geo_is_missing(wkt("LINESTRING (10 inf, nan 2)"))
geo_has_missing(wkt("LINESTRING (10 inf, nan 2)"))
geo_is_finite(wkt("LINESTRING (10 inf, nan 2)"))
geo_is_empty(wkt("LINESTRING (10 inf, nan 2)"))

geo_is_missing(wkt("LINESTRING (10 inf, 1 2)"))
geo_has_missing(wkt("LINESTRING (10 inf, 1 2)"))
geo_is_finite(wkt("LINESTRING (10 inf, 1 2)"))
geo_is_empty(wkt("LINESTRING (10 inf, 1 2)"))

# EMPTY geometries are considered finite and non-missing
geo_is_missing(wkt("LINESTRING EMPTY"))
geo_has_missing(wkt("LINESTRING EMPTY"))
geo_is_finite(wkt("LINESTRING EMPTY"))
geo_is_empty(wkt("LINESTRING EMPTY"))

# POINT EMPTY, POINT (nan nan), and geo_xy(NA, NA)
# are all empty points
geo_is_missing(wkt("POINT EMPTY"))
geo_has_missing(wkt("POINT EMPTY"))
geo_is_finite(wkt("POINT EMPTY"))
geo_is_empty(wkt("POINT EMPTY"))

geo_is_missing(wkt("POINT (nan nan)"))
geo_has_missing(wkt("POINT (nan nan)"))
geo_is_finite(wkt("POINT (nan nan)"))
geo_is_empty(wkt("POINT (nan nan)"))

geo_is_missing(geo_xy(NA, NA))
geo_has_missing(geo_xy(NA, NA))
geo_is_finite(geo_xy(NA, NA))
geo_is_empty(geo_xy(NA, NA))

paleolimbot/geovctrs documentation built on July 30, 2020, 3:41 p.m.