check_wkt: Check input WKT

Description Usage Arguments Examples

View source: R/check_wkt.r

Description

Check input WKT

Usage

1
check_wkt(wkt = NULL, skip_validate = FALSE)

Arguments

wkt

(character) one or more Well Known Text objects

skip_validate

(logical) whether to skip wellknown::validate_wkt call or not. Default: FALSE

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
check_wkt('POLYGON((30.1 10.1, 10 20, 20 60, 60 60, 30.1 10.1))')
check_wkt('POINT(30.1 10.1)')
check_wkt('LINESTRING(3 4,10 50,20 25)')

# check many passed in at once
check_wkt(c('POLYGON((30.1 10.1, 10 20, 20 60, 60 60, 30.1 10.1))',
  'POINT(30.1 10.1)'))

# bad WKT
# wkt <- 'POLYGON((30.1 10.1, 10 20, 20 60, 60 60, 30.1 a))'
# check_wkt(wkt)

# many wkt's, semi-colon separated, for many repeated "geometry" args
wkt <- "POLYGON((-102.2 46.0,-93.9 46.0,-93.9 43.7,-102.2 43.7,-102.2 46.0))
;POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))"
check_wkt(gsub("\n", '', wkt))

## End(Not run)

Example output

[1] "POLYGON((30.1 10.1, 10 20, 20 60, 60 60, 30.1 10.1))"
[1] "POINT(30.1 10.1)"
[1] "LINESTRING(3 4,10 50,20 25)"
[1] "POLYGON((30.1 10.1, 10 20, 20 60, 60 60, 30.1 10.1))"
[2] "POINT(30.1 10.1)"                                    
[1] "POLYGON((-102.2 46.0,-93.9 46.0,-93.9 43.7,-102.2 43.7,-102.2 46.0))"
[2] "POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))"                

rgbif documentation built on June 2, 2021, 9:07 a.m.