# To project, or not to project? Extracting raster values with R

I have a raster from which I need to extract values at point locations using `raster::extract(raster_stack, points_sf)`.

The raster is at 30 arc-second resolution and came from WorldClim with proj4string: `"+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"`

i.e. it's coordinates are geographic on an ellipsoid. My point location data has the same lon-lat WGS84 CRS.

I've noticed that about 3/4 of the values I extract differ depending on whether or not I've transformed both the raster and the points to a planar projection with proj4string:

``````"+proj=laea +lat_0=43.15268 +lon_0=-70.30744 +x_0=12019341.4
+y_0=1730136  +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs".
``````

My question is, should I expect points to move between raster cells this much as a result of projection? And which method is more accurate? In case spatial scale matters, the bounding box for the points is:

``````     xmin      ymin      xmax      ymax
-73.68631  41.01861 -67.89930  45.23919
``````

Please let me know in the comments if this question needs a reproducible example.

## 1 Answer

Reprojecting rasters is usually a bad thing to do. It involves a non-reversible transformation from one grid system to another grid system that can have a non-linear relationship to the first. Hence the value in a cell of the new system can end up being some average of whichever grid cells in the source raster it overlapped.

If you have a raster and points in the same coordinate system, work with that.

If you have a raster and points in a different coordinate system, reproject the points to the raster system (since that is a precise and reversible transformation with no information loss).

Only if you have two rasters with different coordinate systems and you want to do some kind of operation between them should you think about reprojecting one of them.