Hello all: I am having trouble running a geographically weighted regression on raster data using R (raster, spgwr, and sp packages) and was hoping someone on here might have some guidance.
I keep getting two different errors when troubleshooting my model. "'dimnames' applied to non-array" or "new data matrix rows mismatch." In order to test my model, I am using simulated data that I made to ensure no missing data values. I have two datasets that I am looking at: BBS and Fire. To my knowledge these errors mean there is missing data, but I can't seem to find any. Does anyone have any insight into these errors? I can't seem to find a good explanation online. I'd be happy to provide any extra output/data examples if needed. Below is my code: Data Import and Setup > BBSSmall=raster("Simulation/BBSraster_Sim_Clip.tif") > FireSmall=raster("Simulation/FireWhole_Clip.tif") > FireSmall_proj=projectRaster(FireSmall,BBSSmall) > alldata2=brick(BBSSmall,FireSmall_proj) > df2=as.data.frame(getValues(alldata2)) Data > FireSmall_proj class : RasterLayer dimensions : 577, 649, 374473 (nrow, ncol, ncell) resolution : 100, 100 (x, y) extent : 1050330, 1115230, 1117886, 1175586 (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 data source : in memory names : FireWhole_Clip values : -2.349897, 12.19254 (min, max) > BBSSmall class : RasterLayer dimensions : 577, 649, 374473 (nrow, ncol, ncell) resolution : 100, 100 (x, y) extent : 1050330, 1115230, 1117886, 1175586 (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 data source : C:\Users\Baruch\Documents\James GIS\BBS\Simulation\BBSraster_Sim_Clip.tif names : BBSraster_Sim_Clip values : 8.053012, 35.7119 (min, max) Importing Test Area to Get Coordinates of Each Pixel > TestSmall=raster("Simulation/NewTestSmall.tif") > spts2=rasterToPoints(TestSmall,spatial=TRUE) > geoproj2=proj4string(TestSmall) > geoproj2 *[1] "+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"* > Testpts2=spTransform(spts2,CRS(geoproj2)) Model >model=gwr(getValues(BBSSmall)~getValues(FireSmall_proj),data=df2,coords =Testpts2,bandwidth=1000) ***Error in `colnames<-`(`*tmp*`, value = c("coord.x", "coord.y")) : 'dimnames' applied to non-array*** Using Coordinates (Testpts) as a data frame > Testpts3=as.data.frame(Testpts2) >model2=gwr(getValues(BBSSmall)~getValues(FireSmall_proj),coords=Testpts 3,bandwidth=1000) **Error in gwr(getValues(BBSSmall) ~ getValues(FireSmall_proj), coords = Testpts3, : new data matrix rows mismatch** Thanks in advance, -J