[R-sig-Geo] image background for spplot of gridded data
Agustin Lobo
alobolistas at gmail.com
Tue Dec 10 17:19:31 CET 2013
Yes!
I also noticed that making a custom box for the plot is not
straightforward because
the user cannot set the box in get_map. I've managed to do it using
the extend() trick.
html updated
https://dl.dropboxusercontent.com/u/3180464/contourOngmap_log.html
Thanks!
Agus
On Tue, Dec 10, 2013 at 3:10 PM, Oscar Perpiñan
<oscar.perpinan at gmail.com> wrote:
> Try this:
>
> rinvmod2Ext <- extend(rinvmod2lonlat,
> with(bbMap2, c(ll.lon, ur.lon, ll.lat, ur.lat)))
>
> contourplot(rinvmod2Ext, zscaleLog=TRUE, margin=FALSE) +
> layer(grid.raster(gmap2,
> x=lonCenter2, y=latCenter2,
> width=width2, height=height2,
> default.units='native'),
> under=TRUE)
>
> Best,
>
> Oscar.
> -----------------------------------------------------------------
> Oscar Perpiñán Lamigueiro
> Grupo de Sistemas Fotovoltaicos (IES-UPM)
> Dpto. Ingeniería Eléctrica (ETSIDI-UPM)
> URL: http://oscarperpinan.github.io
> Twitter: @oscarperpinan
>
>
> 2013/12/10 Agustin Lobo <alobolistas at gmail.com>:
>> Yes, it does for me as well: I had messed with the parameters of the
>> map in the original function.
>> Here I've made a page showing what I do and what I get:
>> https://dl.dropboxusercontent.com/u/3180464/contourOngmap_log.html
>>
>> Is it possible doing the reverse, overlaying the contour on top of the
>> map instead of putting the map under the contour?
>> I need the plume in the context of the country.
>>
>> Agus
>>
>>
>> Agus
>>
>> On Tue, Dec 10, 2013 at 11:51 AM, Oscar Perpiñan
>> <oscar.perpinan at gmail.com> wrote:
>>> It works for me using rinvmod2lonlat (long-lat coordinates).
>>>
>>> Oscar.
>>> -----------------------------------------------------------------
>>> Oscar Perpiñán Lamigueiro
>>> Grupo de Sistemas Fotovoltaicos (IES-UPM)
>>> Dpto. Ingeniería Eléctrica (ETSIDI-UPM)
>>> URL: http://oscarperpinan.github.io
>>> Twitter: @oscarperpinan
>>>
>>>
>>> 2013/12/10 Agustin Lobo <alobolistas at gmail.com>:
>>>> and would it possible a similar plot using contourplot() (or
>>>> levelplot()) overlaid
>>>> on a gmap?
>>>>
>>>> I've tried the equivalent to the
>>>> stamen.R function that you refer to:
>>>>
>>>> contourplot(rinvmod2goog,zscaleLog=TRUE,
>>>> at=my.at,colorkey=myColorkey,margin=FALSE,add=TRUE) +
>>>> layer(grid.raster(gmap2,
>>>> x=lonCenter2, y=latCenter2,
>>>> width=width2, height=height2,
>>>> default.units='native'),under=TRUE)
>>>>
>>>> and get no error but just the contour. I've tried with my object in
>>>> pseudomercator and "lon-lat" geographic coordinates:
>>>> rinvmod2goog <- projectRaster(from=rinvmod2, crs=CRS("+init=epsg:3857"))
>>>> rinvmod2lonlat <- projectRaster(from=rinvmod2, crs=CRS("+proj=longlat
>>>> +ellps=WGS84 +no_defs"))
>>>>
>>>> both rinvmod2 and and gmap2 display fine independently.
>>>>
>>>> Data:
>>>> https://dl.dropboxusercontent.com/u/3180464/rinvmod2.rda
>>>> https://dl.dropboxusercontent.com/u/3180464/gmap2.rda
>>>> (to be used with load())
>>>>
>>>> Thanks
>>>>
>>>> Agus
>>>>
>>>> On Wed, Nov 20, 2013 at 6:47 PM, Oscar Perpiñan
>>>> <oscar.perpinan at gmail.com> wrote:
>>>>> Hi,
>>>>>
>>>>> For the sake of completeness: just a few days ago I received a comment
>>>>> to a post about spplot and ggmap
>>>>> (http://procomun.wordpress.com/2013/04/24/stamen-maps-with-spplot/).
>>>>> There I was using a SpatialPointsDataFrame object. Because of that
>>>>> comment I posted another example with SpatialPolygonsDataFrame:
>>>>> https://gist.github.com/oscarperpinan/7482848
>>>>>
>>>>> Best,
>>>>>
>>>>> Oscar.
>>>>> -----------------------------------------------------------------
>>>>> Oscar Perpiñán Lamigueiro
>>>>> Grupo de Sistemas Fotovoltaicos (IES-UPM)
>>>>> Dpto. Ingeniería Eléctrica (ETSIDI-UPM)
>>>>> URL: http://oscarperpinan.github.io
>>>>> Twitter: @oscarperpinan
>>>>>
>>>>>
>>>>> 2013/11/20 Waichler, Scott R <Scott.Waichler at pnnl.gov>:
>>>>>> I was told, among other things, to look for previous messages by Oscar that would explain how to do this. Here is Oscar's solution that I found to work for the case where you want to plot two rasters that have different extents. In my case, gmap is a satellite image obtained with RgoogleMaps, and z are the results I want to plot over the background image. I made the alpha values of z less than 1 so that the background image would show through.
>>>>>>
>>>>>> library(rasterVis)
>>>>>> levelplot(z~x*y) +
>>>>>> layer_(grid.raster(gmap, y=latCenter, width=width, height=height, default.units='native'))
>>>>>>
>>>>>> Scott Waichler
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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
>>>
>>> _______________________________________________
>>> 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
More information about the R-sig-Geo
mailing list