Convert a bounding box to a Well Known Text polygon, and a WKT to a bounding box

Share:

Description

Convert a bounding box to a Well Known Text polygon, and a WKT to a bounding box

Usage

1
2
3
gbif_bbox2wkt(minx = NA, miny = NA, maxx = NA, maxy = NA, bbox = NULL)

gbif_wkt2bbox(wkt = NULL)

Arguments

minx

Minimum x value, or the most western longitude

miny

Minimum y value, or the most southern latitude

maxx

Maximum x value, or the most eastern longitude

maxy

Maximum y value, or the most northern latitude

bbox

A vector of length 4, with the elements: minx, miny, maxx, maxy

wkt

A Well Known Text object.

Value

gbif_bbox2wkt returns an object of class charactere, a Well Known Text string of the form 'POLYGON((minx miny, maxx miny, maxx maxy, minx maxy, minx miny))'.

gbif_wkt2bbox returns a numeric vector of length 4, like c(minx, miny, maxx, maxy).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
# Convert a bounding box to a WKT
## Pass in a vector of length 4 with all values
mm <- gbif_bbox2wkt(bbox=c(38.4,-125.0,40.9,-121.8))
read_wkt(mm)

## Or pass in each value separately
mm <- gbif_bbox2wkt(minx=38.4, miny=-125.0, maxx=40.9, maxy=-121.8)
read_wkt(mm)

# Convert a WKT object to a bounding box
wkt <- "POLYGON((38.4 -125,40.9 -125,40.9 -121.8,38.4 -121.8,38.4 -125))"
gbif_wkt2bbox(wkt)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.