Skip to content

plot raster over google map

5 messages · Barry Rowlingson, Robert J. Hijmans, Ross Ahmed

#
On Thu, Feb 28, 2013 at 5:03 PM, Ross Ahmed <rossahmed at googlemail.com> wrote:
You've created a raster with an extent in lat-long coordinates, but
assigned it a very non lat-long projection CRS.

 gmap has done a couple of things, it has got the google map for the
lat-long extent you requested, but returned a raster in google's CRS.
It's not a lat-long grid.

 > extent(g)
class       : Extent
xmin        : -213661.6
xmax        : -192526.8
ymin        : 7476426
ymax        : 7500886

 > extent(myExtent)
class       : Extent
xmin        : -1.8771
xmax        : -1.772096
ymin        : 55.61399
ymax        : 55.68217
You need to stop lying to your raster, and tell it it really is a
raster in lat-long, then project it to the google map CRS:

 > 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

Barry
#
Brilliant, thanks


On 28/02/2013 17:52, "Barry Rowlingson" <b.rowlingson at lancaster.ac.uk>
wrote: