1

I am working with two rasters. I am trying to reproject r1 the same way as the raster r2. Rasters are available here

r1

class       : RasterLayer 
dimensions  : 30286, 58025, 1757345150  (nrow, ncol, ncell)
resolution  : 99.99876, 99.99876  (x, y)
extent      : -2893269, 2909160, 224962.6, 3253525  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0 
values      : 0, 7 (min, max)

r2

class       : RasterLayer 
dimensions  : 585, 1386, 810810  (nrow, ncol, ncell)
resolution  : 0.04166599, 0.041666  (x, y)
extent      : 235.207, 292.9561, 25.04224, 49.41686  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +no_defs 
values      : -7.904284, 12.21496  (min, max)

I precise that the resolution of r1 is 100 m and the resolution of r2 is supposed to be 4km. Moreover, the system of coordinates is different as one is in degree and another one in meter. I would like to reproject the rasters in order they keep their own resolution and share the same extent.

I did not find a way to do it. When I upload my data in Arcgis, the rasters are aligned as I would like which is not the case with Qgis and R. The final goal would be to allow raster calculations by stacking the raster for example.

I do not want to reproject the raster from r2 to r1 as I am working with thousands of raster that have the same coordinates than r2.

I can work with Arcgis, Qgis, and R. However, I do not know how to code in Python.

Currently, by applying the method by Spacedman (answers below), I obtainedthis figure. This is much better as my rasters are closers but there are still not at the same position when I plot them. Moreover, the resolution of r1 has changed. I am confused to what is the problem.

1

The extent of r2 is giving problems because its not in the longitude range -180 to 180, but probably 0 to 360:

extent      : 235.207, 292.9561, 25.04224, 49.41686  (xmin, xmax, ymin, ymax)

If you fix that then:

r1p = projectRaster(r1, r2)

will work nicely.

You can fix this by reassigning the extent of a raster to a new extent with the X coordinates minus 360:

> r2
class       : RasterLayer 
dimensions  : 585, 1386, 810810  (nrow, ncol, ncell)
resolution  : 0.04166599, 0.041666  (x, y)
extent      : 235.207, 292.9561, 25.04225, 49.41686  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +no_defs 
data source : in memory
names       : layer 
values      : 1, 810810  (min, max)

> extent(r2) = extent(xmin(r2)-360, xmax(r2)-360, ymin(r2), ymax(r2))
> r2
class       : RasterLayer 
dimensions  : 585, 1386, 810810  (nrow, ncol, ncell)
resolution  : 0.04166602, 0.04166602  (x, y)
extent      : -124.793, -67.0439, 25.04224, 49.41686  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +no_defs 
data source : in memory
names       : layer 
values      : 1, 810810  (min, max)
  • Thank you for your comments. However, it improves a lot. However, how could I have my rasters like superposed? Currently it improves a lot the reproduction but they are not displayed at the same location. And do you know how I could use projectRaster in a way r1 does not change its spatial resolution (keep it to 100, 100)? Thanks in advance! – LMontef May 12 at 21:57
  • You need to create a 100x100 raster that covers the projected extent of the source raster. However I'm not sure I really understand the rest of your comment. Perhaps if you edited your question and included some maps that would improve things. – Spacedman May 12 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.