Gpplot cannot plot SpatialPixelsDataFrame's in one go. You need to 
convert the grid to a data frame.

An example using the meuse dataset:

library(sp)
library(ggplot2)
data(meuse.grid)
gridded(meuse.grid) = ~x+y
summary(meuse.grid)

meuse.grid_df = as(meuse.grid, "data.frame")

# Now make a plot with ggplot
p = ggplot(aes(x = x, y = y, fill = dist), data = meuse.grid_df) +
   geom_tile()
print(p)

# Add some tricks specially suitable for
# spatial plots
print(p +
      scale_x_continuous('', labels = NA, breaks = NA) +
      scale_y_continuous('', labels = NA, breaks = NA) +
     opts(aspect.ratio = 1, alpha = 0.5))

cheers,
Paul

On 11/06/2010 02:28 PM, Manuel Spínola wrote:
> Thank you very much Paul.
>
> With plot I got a black polygon and with spplpot I got:
>
> > spplot(riquezakrig)
> Error: cannot allocate vector of size 22.6 Mb
>
> with image show me what I want but no legend.
>
> Any specific geom to plot with ggplot?
>
> Best,
>
> Manuel
>
> On 06/11/2010 06:46 a.m., Paul Hiemstra wrote:
>> On 11/06/2010 11:15 AM, Manuel Spínola wrote:
>>> Dear list members,
>>>
>>> I read a .tif file with readGDAL.
>>> What is the best way to display it?.
>>>    
>> spplot or ggplot
>>> I tried function image but there is no legend.
>>>    
>> true
>>> I tried plot and spplot but I couldn't get them to work.
>>>    
>> why not? What error? What version of R and sp? You're not giving us 
>> any information that could give us a clue to what's going wrong.
>>
>> cheers,
>> Paul
>>> Any help will be appreciated.
>>>
>>> Best,
>>>
>>> Manuel
>>>
>>>
>>>    
>>>
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo@stat.math.ethz.ch
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>    
>>
>>
>> -- 
>> Drs. Paul Hiemstra
>> Department of Physical Geography
>> Faculty of Geosciences
>> University of Utrecht
>> Heidelberglaan 2
>> P.O. Box 80.115
>> 3508 TC Utrecht
>> Phone:  +3130 253 5773
>> http://intamap.geo.uu.nl/~paul
>> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
>
>
> -- 
> *Manuel Spínola, Ph.D.*
> Instituto Internacional en Conservación y Manejo de Vida Silvestre
> Universidad Nacional
> Apartado 1350-3000
> Heredia
> COSTA RICA
> mspin...@una.ac.cr
> mspinol...@gmail.com
> Teléfono: (506) 2277-3598
> Fax: (506) 2237-7036
> Personal website: Lobito de río 
> <https://sites.google.com/site/lobitoderio/>
> Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>


-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 253 5773
http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to