Question

Let us have an extent object:

> require(raster)
> e <- extent(0,20,35,60)
> e
class       : Extent 
xmin        : 0 
xmax        : 20 
ymin        : 35 
ymax        : 60

How to get the extent coordinates out of it in a more compact way than just using xmin(e), ymin(e) .... ?

EDIT: I actually needed this for saving the extent of drawExtent for further use to construct the extent:

> catalunya <- drawExtent()
> catalunya
class       : Extent 
xmin        : -0.3026625 
xmax        : 4.399662 
ymin        : 39.4917 
ymax        : 43.55101
> dput(c(t(bbox(catalunya))))
c(-0.302662510572699, 4.39966213295851, 39.4917044713409, 43.5510057541513

Copy and paste this as a parameter to extent() to my script. DONE.

Was it helpful?

Solution

> require(sp)
> bbox(e)
   min max
s1   0  20
s2  35  60

Bbox can be also used to create extent object:

> extent(bbox(e))
class       : Extent 
xmin        : 0 
xmax        : 20 
ymin        : 35 
ymax        : 60
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top