[R-sig-Geo] contours in SpatialPixelsDataFrame
Agustin Lobo
alobolistas at gmail.com
Wed Dec 11 08:36:51 CET 2013
Thanks Agus Camacho,
but this is essentially what I was doing: create a raster (an image is
a raster) out of the points
and then use contour() or the more sophisticated
rasterVis::contourplot or levelplot. In this
particular case the raster can be created with no interpolation, as
the points are arranged as a grid
and the spatial resolution is already the one we had selected for the
dispersion model.
The question was if the conversion to raster could be skipped, which
is the case in the way Oscar
kindly indicated.
Agus
On Tue, Dec 10, 2013 at 6:36 PM, Agus Camacho <agus.camacho at gmail.com> wrote:
> Maybe too obvious to be useful, but have you tried using the "akima"
> package for plotting your variable?
>
> It only needs the coordinates and the value of your variable:
>
>
> require(akima)
> data(akima)
> ## linear interpolation
> akima.li <- interp(akima$x, akima$y, akima$z)
> image (akima.li, add=TRUE)
> contour(akima.li, add=TRUE)
> points (akima, pch = 3)
>
> Saludos
> Agus
>
>
>
> 2013/12/10 Oscar Perpiñan <oscar.perpinan at upm.es>
>
>> Hi,
>>
>> spplot for SpatialPixelsDataFrame is built upon lattice::levelplot.
>> Thus, you can use most of its arguments in spplot. For your problem
>> you have to set "contour=TRUE" and "region=FALSE". Moreover, you can
>> customize the labels with (surprise!) "labels". This is documented in
>> the help page of lattice::panel.levelplot:
>>
>> library(sp)
>> data(meuse.grid)
>> m <- SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")],
>> data = meuse.grid)
>>
>> spplot(m["dist"],
>> contour=TRUE, region=FALSE,
>> labels=list(cex=0.6))
>>
>> Best,
>>
>> Oscar.
>> -----------------------------------------------------------------
>> Oscar Perpiñán Lamigueiro
>> Dpto. Ingeniería Eléctrica (ETSIDI-UPM)
>> Grupo de Sistemas Fotovoltaicos (IES-UPM)
>> URL: http://oscarperpinan.github.io
>> Twitter: @oscarperpinan
>>
>>
>> 2013/12/9 Agustin Lobo <alobolistas at gmail.com>:
>> > I have a set of regularly distributed points (a grid) as a SpatialPoints
>> DF.
>> > In order to display the distribution of a continuos varaible in the data
>> table,
>> > I transform to SpatialPixelsDataFrame (using gridded(a) <- TRUE)
>> > and after calculating the dimensions of the grid I use rasterize() to
>> convert
>> > to raster and then use rasterVIS::levelplot()
>> >
>> > My question is, can equivalent contours be drawn directely on the
>> > SpatialPixelsDataFrame object
>> > to skip the tansform to raster?
>> > I've tried with spplot(), but get filled intervals, not line contours.
>> >
>> > Thanks
>> >
>> > Agus
>> >
>> > _______________________________________________
>> > R-sig-Geo mailing list
>> > R-sig-Geo at r-project.org
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>
>
> --
> Agustín Camacho Guerrero.
> Doutor em Zoologia.
> Laboratório de Herpetologia, Departamento de Zoologia, Instituto de
> Biociências, USP.
> Rua do Matão, trav. 14, nº 321, Cidade Universitária,
> São Paulo - SP, CEP: 05508-090, Brasil.
>
> [[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
>
More information about the R-sig-Geo
mailing list