Hi Robert

Many thanks for your answer yesterday ­ very useful. I tried lonlat=T and it
didnšt work for. Herešs  the code lifted from my history:

myExtent <- matrix(c(-1.87710, -1.772096, 55.61399, 55.682171), ncol=2,
byrow=T)
rownames(myExtent) <- c('long', 'lat')
colnames(myExtent) <- c('min', 'max')
rasterExtent <- extent(myExtent)
myRaster   <- raster(ext=rasterExtent,crs="+proj=longlat +datum=WGS84
+ellps=WGS84")
values(myRaster) <- rnorm(ncell(myRaster))
g <- gmap(myExtent, type='hybrid', interpolate=T, lonlat=T)
plot(g, interpolate=TRUE)
plot(myRaster, add=T, alpha=0.5)

As far as I can tell, both the raster and the google map are projected using
WSG84. Apologies in advance if theres any ignorance here ­ absolute
beginner!

Thanks
Ross

From:  "Robert J. Hijmans" <r.hijmans@gmail.com>
Date:  Thursday, 28 February 2013 19:03
To:  Ross Ahmed <rossahmed@googlemail.com>
Cc:  Barry Rowlingson <b.rowlingson@lancaster.ac.uk>,
"r-sig-geo@r-project.org" <r-sig-geo@r-project.org>
Subject:  Re: [R-sig-Geo] plot raster over google map

Ross, 
And please carefully study the answers to your previous queries; and
carefully read the manual.
Yesterday I showed that you can do something like
"g <- gmap('Bolivia', lonlat=TRUE)"
such that gmap returns a longitude/latitude raster.
Robert

On Thu, Feb 28, 2013 at 10:22 AM, Ross Ahmed <rossahmed@googlemail.com>
wrote:
> Brilliant, thanks
> 
> 
> On 28/02/2013 17:52, "Barry Rowlingson" <b.rowlingson@lancaster.ac.uk>
> wrote:
> 
>>> >> projection(myRaster)="+init=epsg:4326"  # lat-long WGS84
>>> >> pRaster =projectRaster(myRaster, crs=projection(g)) # reproject to
>> >the google CRS (no need to type it all in again)
>>> >> plot(pRaster,add=TRUE) # shazam
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo




	[[alternative HTML version deleted]]

