[R-sig-Geo] extracting coordinates

Roger Bivand Roger.Bivand at nhh.no
Mon Feb 28 21:35:41 CET 2011


On Mon, 28 Feb 2011, Robin W Hunnewell wrote:

> Hi again,
> Thanks, sorry about that - here is the code to illustrate what I did 
> - following the ASDAR book example of choosing a subset of coordinates in 
> Brazil:

Thanks for a clear report, this was a bug introduced three months ago. A 
patched sp can be downloaded from late evening tomorrow at SVN revision 
1037 from R-Forge, either

install.packages("sp", repos="http://R-Forge.R-project.org")

or visit

https://r-forge.r-project.org/R/?group_id=1014

and download manually. I'm sorry I didn't make this evening's pickup at 
20:30 CET.

Roger

>
>> brazil
> [1] 4 5 6 7 8
>> coordinates(CRAN_sp[brazil, ])
>   coords.x1 coords.x2
> 4 -49.26667 -25.41667
> 5 -42.86667 -20.75000
> 6 -43.20000 -22.90000
> 7 -47.63333 -22.71667
> 8 -46.63333 -23.53333
>> summary(CRAN_sp[brazil, ])
> Object of class SpatialPoints
> Coordinates:
>                  min      max
> coords.x1 -122.95000 153.0333
> coords.x2  -37.81667  57.0500
> Is projected: FALSE 
> proj4string : [+proj=longlat +ellps=WGS84]
> Number of points: 5
>
>> summary(CRAN_sp)
> Object of class SpatialPoints
> Coordinates:
>                  min      max
> coords.x1 -122.95000 153.0333
> coords.x2  -37.81667  57.0500
> Is projected: FALSE 
> proj4string : [+proj=longlat +ellps=WGS84]
> Number of points: 54
>
>   
> My problem is: the object "brazil" should have a new bounding box -- as it 
> does in the ASDAR book example text. But when I do it, the bounding box 
> remains identical to the original one for CRAN_sp.
> Sorry for the confusion, thanks greatly for any help.
> Robin
>
>
>
> Begin forwarded message:
>
> From: Tom Gottfried <tom.gottfried at wzw.tum.de>
> Date: February 28, 2011 1:05:21 PM
> To: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] extracting coordinates
>
> Hi Robin,
>
> could you please post some example code (possibly self-contained, e.g. with 
> meuse data)?
> So it's less guessing what you actually did. More on this topic:
> http://www.r-project.org/posting-guide.html
>
> regards,
> Tom
>
> Am 28.022011 16:59, schrieb Robin W Hunnewell:
>> Hi,
>> 
>> I'm going through some initial data inspection, and working through
>> steps in the "Applied Spatial Data analysis with R" book. Following steps 
>> in Ch. 2 of the "Applied Spatial Data analysis with R"
>> book, I was able to extract a set of coordinates from my
>> SpatialPoints object just fine. The object returned looks right - the
>> coordinates are extracted correctly, but my bounding box does not change. 
>> The same min/max for coords.x1 and x2 get returned instead
>> of a new bounding box that reflects the selection.
>> 
>> Not sure what I'm missing, would appreciate any help - I apologize if
>> this is overly simple!
>> thanks,
>> Robin
>> 
>> 
>> 
>> _______________________________________________
>> 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


More information about the R-sig-Geo mailing list