[R-sig-Geo] Newbie Question...

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Jan 5 08:22:54 CET 2010



Michael Sumner wrote:
> Here's one way. I'm not sure about how to control the aspect ratio
> (something I've been meaning to check for a while now).
>   
somewhat of a non-newby answer to Michael: asp is set in plot.Spatial, 
and if the default value of NA is passed, set to:

    if (is.na(asp)) asp <- ifelse(is.na(proj4string(x)) || is.projected(x),
        1.0, 1/cos((mean(ylim) * pi)/180))

i.e. 1.0, or a somewhat more sensible value for longlat data.

if you override the NA default with "", asp is taken from the device 
geometry -- the plot fills the device. For geographic data this usually 
means arbitrary stretching in some direction.

> library(sp)
> data(volcano)
> x <- 10*(1:nrow(volcano))
> y <- 10*(1:ncol(volcano))
>
> ## image xyz list
> imlist <- list(x = x, y = y, z = volcano)
>
> ## SpatialGridDataFrame (image2Grid is v. simple, see definition)
> imspdf <- image2Grid(imlist)
>
> image(imspdf, col = terrain.colors(100),axes = FALSE, asp = "")
> contour(imspdf, levels = seq(90, 200, by=5),add = TRUE, col ="peru")
> axis(1, at = seq(100, 800, by = 100))
> axis(2, at = seq(100, 600, by = 100))
> box()
> title(main = "Maunga Whau Volcano",font.main = 4)
>
>
>
> On Tue, Jan 5, 2010 at 1:34 PM, Jason Rupert <jasonkrupert at yahoo.com> wrote:
>   
>> At the suggestion of Walmes Zeviani I downloaded and am taking a look at the sp package.
>>
>> In an attempt to get going, can someone offer a suggestion about how to convert the below over to a version that uses the sp package?
>>
>> data(volcano)
>> x <- 10*(1:nrow(volcano))
>> y <- 10*(1:ncol(volcano))
>>
>> image(x, y, volcano,col = terrain.colors(100),axes = FALSE)
>> contour(x, y, volcano, levels = seq(90, 200, by=5),add = TRUE, col ="peru")
>> axis(1, at = seq(100, 800, by = 100))
>> axis(2, at = seq(100, 600, by = 100))
>> box()
>> title(main = "Maunga Whau Volcano",font.main = 4)
>>
>> Thanks for any feedback and insights.
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>     
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> 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



More information about the R-sig-Geo mailing list