An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110529/978e2993/attachment.pl>
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:
Dear R Sig Geo People: I have a large data frame which includes dates and times as columns. I want to have one map (via writeOGR) which has the whole thing, and then have several maps by days. However, I want the whole area as defined by the entire data set to show every day. I looked at bbox but I can't set a bbox. How would I set the coordinates, please? Maybe use the coordinates function with the big set structure, please? Thanks, Have a great weekend, Sincerely, Erin Erin M. Hodgess, PhD Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: hodgesse at uhd.edu [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Edzer Pebesma Institute for Geoinformatics (ifgi), University of M?nster Weseler Stra?e 253, 48151 M?nster, Germany. Phone: +49 251 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de http://www.52north.org/geostatistics e.pebesma at wwu.de
On Sun, May 29, 2011 at 8:16 PM, Hodgess, Erin <HodgessE at uhd.edu> wrote:
I want to have one map (via writeOGR) which has the whole thing, and then have several maps by days. However, I want the whole area as defined by the entire data set to show every day. I looked at bbox but I can't set a bbox.
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:
On Sun, May 29, 2011 at 8:16 PM, Hodgess, Erin <HodgessE at uhd.edu> wrote:
I want to have one map (via writeOGR) which has the whole thing, and then have several maps by days. However, I want the whole area as defined by the entire data set to show every day. I looked at bbox but I can't set a bbox.
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)
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
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
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no
plot(as(m, "Spatial"))
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...
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.
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:
plot(as(m, "Spatial"))
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))
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
despite the warning about Spatial being an abstract class...
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.
Texas may be awake now, but I think it might be a holiday in the USA... Barry
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no
On Mon, 30 May 2011, Roger Bivand wrote:
On Mon, 30 May 2011, Barry Rowlingson wrote:
plot(as(m, "Spatial"))
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))
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.
Ahh - plot(as(r, "Spatial")) ...
Roger
despite the warning about Spatial being an abstract class...
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.
Texas may be awake now, but I think it might be a holiday in the USA... Barry
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no