R/wkt_parse.R

Defines functions wkt_parse

Documented in wkt_parse

#' parse wkt into smaller bits
#'
#' @export
#' @param wkt (character) A WKT string. Required.
#' @param geom_big (character) Only "bbox" works since rgbif 3.8.0. 
#' @param geom_size (integer) An integer indicating size of the cell.
#' Default: 40.
#' @param geom_n (integer) An integer indicating number of cells in
#' each dimension. Default: 10.
#' @examples
#' wkt <- "POLYGON((13.26349675655365 52.53991761181831,18.36115300655365 54.11445544219924,
#' 21.87677800655365 53.80418956368524,24.68927800655365 54.217364774722455,28.20490300655365
#' 54.320018299365124,30.49005925655365 52.85948216284084,34.70880925655365 52.753220564427814,
#' 35.93927800655365 50.46131871049754,39.63068425655365 49.55761261299145,40.86115300655365
#' 46.381388009130845,34.00568425655365 45.279102926537,33.30255925655365 48.636868465271846,
#' 30.13849675655365 49.78513301801265,28.38068425655365 47.2236377039631,29.78693425655365
#' 44.6572866068524,27.67755925655365 42.62220075124676,23.10724675655365 43.77542058000212,
#' 24.51349675655365 47.10412345120368,26.79865300655365 49.55761261299145,23.98615300655365
#' 52.00209943876426,23.63459050655365 49.44345313705238,19.41584050655365 47.580567827212114,
#' 19.59162175655365 44.90682206053508,20.11896550655365 42.36297154876359,22.93146550655365
#' 40.651849782081555,25.56818425655365 39.98171166226459,29.61115300655365 40.78507856230178,
#' 32.95099675655365 40.38459278067577,32.95099675655365 37.37491910393631,26.27130925655365
#' 33.65619609886799,22.05255925655365 36.814081996401605,18.71271550655365 36.1072176729021,
#' 18.53693425655365 39.16878677351903,15.37287175655365 38.346355762190846,15.19709050655365
#' 41.578843777436326,12.56037175655365 41.050735748143424,12.56037175655365 44.02872991212046,
#' 15.19709050655365 45.52594200494078,16.42755925655365 48.05271546733352,17.48224675655365
#' 48.86865641518059,10.62677800655365 47.817178329053135,9.57209050655365 44.154980365192,
#' 8.16584050655365 40.51835445724746,6.05646550655365 36.53210972067291,0.9588092565536499
#' 31.583640057148145,-5.54509699344635 35.68001485298146,-6.77556574344635 40.51835445724746,
#' -9.41228449344635 38.346355762190846,-12.40056574344635 35.10683619158607,-15.74040949344635
#' 38.07010978950028,-14.68572199344635 41.31532459432774,-11.69744074344635 43.64836179231387,
#' -8.88494074344635 42.88035509418534,-4.31462824344635 43.52103366008421,-8.35759699344635
#' 47.2236377039631,-8.18181574344635 50.12441989397795,-5.01775324344635 49.55761261299145,
#' -2.73259699344635 46.25998980446569,-1.67790949344635 44.154980365192,-1.32634699344635
#' 39.30493590580802,2.18927800655365 41.44721797271696,4.47443425655365 43.26556960420879,
#' 2.18927800655365 46.7439668697322,1.83771550655365 50.3492841273576,6.93537175655365
#' 49.671505849335254,5.00177800655365 52.32557322466785,7.81427800655365 51.67627099802223,
#' 7.81427800655365 54.5245591562317,10.97834050655365 51.89375191441792,10.97834050655365
#' 55.43241335888528,13.26349675655365 52.53991761181831))"
#' wkt <- gsub("\n", " ", wkt)
#'
#' if (requireNamespace("sf", quietly=TRUE)) {
#' # to a bounding box in wkt format
#' wkt_parse(wkt, geom_big = "bbox")
#'
#' }
wkt_parse <- function(wkt, geom_big = "bbox", geom_size=40, geom_n=10) {
  geometry_handler(wkt, geom_big, geom_size, geom_n, FALSE)
}
ropensci/rgbif documentation built on May 5, 2024, 5:44 p.m.