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

geo_is_missing(x)

geo_has_missing(x)

geo_is_finite(x)

geo_is_empty(x)

NA_wkt_

NA_wkb_

NA_collection_

NA_xy_

NA_segment_

NA_rect_

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

geo_is_missing(NA_wkt_)
#> [1] TRUE
geo_has_missing(NA_wkt_)
#> [1] NA
geo_is_finite(NA_wkt_)
#> [1] NA
geo_is_empty(NA_wkt_)
#> [1] TRUE
geo_is_missing(wkt("LINESTRING (10 inf, nan 2)"))
#> [1] FALSE
geo_has_missing(wkt("LINESTRING (10 inf, nan 2)"))
#> [1] TRUE
geo_is_finite(wkt("LINESTRING (10 inf, nan 2)"))
#> [1] FALSE
geo_is_empty(wkt("LINESTRING (10 inf, nan 2)"))
#> [1] FALSE
geo_is_missing(wkt("LINESTRING (10 inf, 1 2)"))
#> [1] FALSE
geo_has_missing(wkt("LINESTRING (10 inf, 1 2)"))
#> [1] FALSE
geo_is_finite(wkt("LINESTRING (10 inf, 1 2)"))
#> [1] FALSE
geo_is_empty(wkt("LINESTRING (10 inf, 1 2)"))
#> [1] FALSE
# EMPTY geometries are considered finite and non-missing geo_is_missing(wkt("LINESTRING EMPTY"))
#> [1] FALSE
geo_has_missing(wkt("LINESTRING EMPTY"))
#> [1] FALSE
geo_is_finite(wkt("LINESTRING EMPTY"))
#> [1] TRUE
geo_is_empty(wkt("LINESTRING EMPTY"))
#> [1] TRUE
# POINT EMPTY, POINT (nan nan), and geo_xy(NA, NA) # are all empty points geo_is_missing(wkt("POINT EMPTY"))
#> [1] FALSE
geo_has_missing(wkt("POINT EMPTY"))
#> [1] FALSE
geo_is_finite(wkt("POINT EMPTY"))
#> [1] TRUE
geo_is_empty(wkt("POINT EMPTY"))
#> [1] TRUE
geo_is_missing(wkt("POINT (nan nan)"))
#> [1] FALSE
geo_has_missing(wkt("POINT (nan nan)"))
#> [1] TRUE
geo_is_finite(wkt("POINT (nan nan)"))
#> [1] FALSE
geo_is_empty(wkt("POINT (nan nan)"))
#> [1] FALSE
geo_is_missing(geo_xy(NA, NA))
#> [1] TRUE
geo_has_missing(geo_xy(NA, NA))
#> [1] TRUE
geo_is_finite(geo_xy(NA, NA))
#> [1] FALSE
geo_is_empty(geo_xy(NA, NA))
#> [1] TRUE