I have two rasters and one shape file, all with 100m resolution grids but different extents. The shapefile is slightly smaller extent. I want to make sure they line up exactly so my calculations are correct for each grid cell in future analysis.
Raster 1
day
class : RasterLayer
dimensions : 2367, 2909, 6885603 (nrow, ncol, ncell)
resolution : 0.0008333333, 0.0008333333 (x, y)
extent : -123.6325, -121.2083, 36.8925, 38.865 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
names : DAY_BA
values : 0, 14917 (min, max)
Raster 2
night
class : RasterLayer
dimensions : 2365, 2909, 6879785 (nrow, ncol, ncell)
resolution : 0.0008333333, 0.0008333333 (x, y)
extent : -123.6325, -121.2083, 36.89417, 38.865 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
names : NIGHT_BA
values : 0, 1744 (min, max)
Shapefile
mgrs
class : SpatialPolygonsDataFrame
features : 1186800
extent : -122.6511, -121.594, 37.10124, 38.27151 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
variables : 12
The files are large and loading them and plotting them for visual comparison is yielding nothing interesting.
I tried calculating the distance in meters between the upper and lower extents for each using the functions from https://eurekastatistics.com/calculating-a-distance-matrix-for-geographic-points-using-r/, thinking that increments of 100m would indicate that they are on 100m increment distances from each other, but this did not appear to be the case.
distance.100m <- GeoDistanceInMetresMatrix(df.lims)/100
distance.100m
DayMin DayMax NightMin NightMax MSMin MSMax
DayMin 0.000000 3056.1968 1.906129 3056.1968 903.7839357 2363.0676716
DayMax 3056.196849 0.0000 3054.546060 0.0000 2332.1390496 739.6121652
NightMin 1.906129 3054.5461 0.000000 3054.5461 902.8710503 2361.5160232
NightMax 3056.196849 0.0000 3054.546060 0.0000 2332.1390496 739.6121652
MSMin 903.783936 2332.1390 902.871050 2332.1390 0.0000000 1598.8812655
MSMax 2363.067672 739.6122 2361.516023 739.6122 1598.8812655 0.0000000
Any ideas how to compare that the pixels line up? I want to keep the original values if possible and not resample.