Skip to content
Prev 17658 / 29559 Next

Antw: Re: project google map to Sinusoidal

Hi,
Robert is right, obeyRes is not required as the function res() does exactly what obeyRes was tought for...
I wrote that function because I had to create rasters with a given resolution to fit as good as possible into a given extent and I was trying to do that with raster() that has no "res" argument + obeyRes. So obeyRes was calculation the available ncol/nrow argument in raster()!
But rasterExtent + res() does the job perfectly!
Thanks Matteo
There is some confusion here:
To get a google map in a sinusoidial projection you can do

library(dismo)
# extent
e <- extent(c(-1.87710, -1.772096, 55.61399, 55.682171))
# google map
g <- gmap(e, type='hybrid')
#projection
prj <- "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181
+units=m +no_defs"
# project
s1 <- projectRaster(g, crs=prj)
# done



# for more control
# create empty raster
r <- raster(ext=e,crs="+proj=longlat +ellps=WGS84 +datum=WGS84")
# project extent
r <- projectExtent(r,crs=prj)
# set resolution to desired value
# your value of 1000 seemed too large here.
# I do not think you should obeyRes here
# (I am not sure what it is useful for)
res(r) <- 100
# project
s2 <- projectRaster(g, r)


Hope this clarifies.
Robert
On Fri, Mar 1, 2013 at 5:56 AM, Ross Ahmed wrote:

            
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo