2

I'm having trouble merging two raster datasets that have different resolution and extent, and have irregular point data. Below is info on each raster. I need these datasets to merge according to the grid points so that I can run a fire spread model (which requires both wind and slope data).

I have tried converting to normal dataframes (using rasterToPoints) before merging but the differences lead to loss of a lot of grid points.

I have tried to align the rasters with project raster and rasterize, but I haven't managed to get it to work. If anyone has an idea that could help, I would really appreciate your answer!

'''

Data from https://globalwindatlas.info/downloads/gis-files

> wind <- raster("ZAF_wind-speed_10m.tif"); wind
class      : RasterLayer 
dimensions : 11271, 11804, 133042884  (nrow, ncol, ncell)
resolution : 0.0025, 0.0025  (x, y)
extent     : 13.33407, 42.84407, -50.31423, -22.13673  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +datum=WGS84 +no_defs 
source     : C:/Users/s2000128/Documents/Flammability modelling/ZAF/ZAF_wind-speed_10m.tif 
names      : ZAF_wind.speed_10m  

Data from https://datacatalog.worldbank.org/dataset/world-slope-model

> slope <- raster("ZAF1_msk_alt.grd"); slope
class      : RasterLayer 
dimensions : 1548, 1992, 3083616  (nrow, ncol, ncell)
resolution : 0.008333333, 0.008333333  (x, y)
extent     : 16.4, 33, -34.9, -22  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +ellps=WGS84 +no_defs 
source     : C:/Users/s2000128/Documents/Flammability modelling/slope_deg_0/slope_deg/ZAF1_msk_alt.grd 
names      : ZAF1_msk_alt 
values     : -26, 3264  (min, max)

Here are some examples of what I have tried:

1

windresampled <- projectRaster(wind,slope,method = 'ngb'); windresampled

2

wind_points <- rasterToPoints(wind); 
coordinates(wind_points) = ~x+y; 
proj4string(wind_points) = CRS("+init=epsg:4326"); 
gridded(wind_points) = TRUE; 
g_wind <- raster(wind_points); g_wind; 
extent(wind) <- c(16.4,33, -34.9,-22); 
res(wind) <- c(0.0025, 0.0025); 
r_wind <- rasterize(wind_points, g_wind, field = wind_points$z, fun = mean, na.rm = TRUE); r_wind
Sarah
  • 21
  • 1

0 Answers0