Skip to content

newbie bbox type question

7 messages · Hodgess, Erin, Edzer Pebesma, Roger Bivand +1 more

#
Hi Erin,

it is not clear to me whether your goal is to write the data with
writeOGR, or create spatio-temporal data objects and analyse / display
them. OGR (and writeOGR) intrinsically know nothing about time, so
having time as, say attribute columns is the only thing you could do
(AFAIK).

If you want to create space-time objects in R, you might want to try the
functions in package spacetime (e.g. STFDF(), or stConstruct()); when
you're new to the package, start by reading its vignette.

bbox is not something that can be set; coordinates can be set but only
refer to spatial coordinates. The Spatial* objects created by
coordinates<- are a building block for space-time objects.

Hth,
On 05/29/2011 09:16 PM, Hodgess, Erin wrote:

  
    
#
On Sun, May 29, 2011 at 8:16 PM, Hodgess, Erin <HodgessE at uhd.edu> wrote:

            
I think the problem here is that writeOGR doesn't create maps, it
creates data files.

 If you wnt to create a map plot that is based on the bbox of a given
sp object, you can set up an empty plot from its bbox this way:

 > plot(SpatialPoints(t(bbox(m))),cex=0)

 two things to note: I use cex=0 so the points dont show up (because
type="n" doesnt work) and the bbox is transposed because of the way
its rows and columns are arranged.

 Then you can add stuff to the plot area, eg the first polygon:

 > plot(m[1,],add=TRUE)

Not sure if this is what you are really after since its not clear what
your 'map' is and where writeOGR fits into this...

Barry
#
On Mon, 30 May 2011, Barry Rowlingson wrote:

            
Equivalently:

plot(as(m, "Spatial"))

which drops all the unnecessary stuff. I wasn't sure what was needed, 
either. It could be an output file with the data reshaped to "wide" from 
"long", but this is just another guess.

Roger

  
    
#
Coercion with 'as' seems to fail for me:

 > rb=bbox(r)
 > rb
        min       max
x -2.840466 -2.342137
y 54.042700 54.339724
 > as(rb,"Spatial")

Error in as(rb, "Spatial") :
  no method or default for coercing "matrix" to "Spatial"

but using Spatial() works:

 plot(Spatial(rb))

despite the warning about Spatial being an abstract class...
Texas may be awake now, but I think it might be a holiday in the USA...

Barry
#
On Mon, 30 May 2011, Barry Rowlingson wrote:

            
Would plot(as(rb, "Spatial")) work - the object needs to be just "Spatial" 
to just set up the plot device? I didn't check what was what carefully 
enough.

Roger

  
    
#
On Mon, 30 May 2011, Roger Bivand wrote:

            
Ahh - plot(as(r, "Spatial")) ...