On Wed, May 21, 2014 at 5:14 PM, Remi Genevest <rgenev...@free.fr> wrote: > Thanks a lot Barry. Your post perfectly matches what I was looking for. > > Well now if I want to do a coarser grid covering Europe, what I should do is > doing more or less the same thing, just to change the resolution, right? > > res(r)=c(100,100) # an approximate 100meters squared cells > > Then I got my raster in a EU coordinates system, and I would like to > transform it into a WGS 84 (so as adding other layers would become easier). > I tried this way, but it doesn't work : > > # change the CRS into WGS84 (ll) > r.new<-projectRaster(r,crs="+init=epsg:4326") > # adapt the extent to Europe > ext = extent(-10.417,31.917,34.083,71.083) > extent(r.new)<-ext > # plot the map > plot(r.new,axes=TRUE) > # Here I get a plot that is not projected in a proper way.
Oh its very proper. Its just that you've changed the raster between systems that don't have parallel axes. Rasters can only be defined by: origin x,y; cell-size x,y; number of cells in x,y; the coordinate system for x and y. A system like the EU projection maps the sphere onto a cone, and unwraps the cone to a flat surface (topologically speaking a cone is flat - you can make a cone from a flat sheet unlike a sphere). If you have a grid on that basis and want to convert to cells aligned in lat-long, you'll get what looks like a rotated grid. I suspect what you might want is an approximate 100m grid over Europe, aligned on lat-long lines. In which case, you can have 100m cells in the middle of Europe, slightly more closely spaced cells in the north, and slightly further spaced cells in the south - because the grid has to span the same number of degrees over its entire latitude. To make that, work out what 100m is in degrees longitude at your study are mid-latitude, and create a raster from those parameters. You can compute the distance distortion by computing great-circle distances from grid cell coordinates. Barry _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo