0

I'm trying to mimic the raster style output you get from ArcGIS Geographically Weighted Regression, where instead of simply plotting the coefficient/value in the raster cell that aligns with the coordinate point assigned the value leaving all in-between cells NA, it (at least appears to) fill them by a gradient. See ArcGIS screenshot for what I am aiming for. Thanks!

ArcGIS Style Output

R STARS output

R STARS outuput using NA omit

Here's an repex

library(tidyverse)
library(sf)
library(stars)

df <- quakes %>%
  select(depth, long, lat) %>%
  st_as_sf(coords = c("long", "lat"),
           crs = 4326)

df_rast <- st_rasterize(df)

ggplot() +
  geom_stars(data = df_rast)

ggplot() +
  geom_stars(data = df_rast,
             na.action = na.omit)
ttalVlatt
  • 138
  • 6
  • You're more likely to get an answer [here](https://gis.stackexchange.com/). – L Tyrone Apr 08 '23 at 22:18
  • https://cran.r-project.org/web/packages/spgwr/vignettes/GWR.pdf – IRTFM Apr 09 '23 at 03:37
  • 1
    With GWR you run a separate regression model for each cell, giving more weight to nearby than to faraway observations. To fill a gradient by interpolation you could use `terra::: interpIDW(` – Robert Hijmans Apr 09 '23 at 17:04
  • Thanks! I'm aware GWR is estimated for every point, I've just been tasked with reporting it the way ArcGIS does with gradient raster. I will give that terra function a try tomorrow, I think that might be similar to what ArcGIS does behind the scenes – ttalVlatt Apr 10 '23 at 03:12
  • Can you point to the ESRI documentation that explains how it creates its output, because it might be doing something like inverse distance weighting, which is essentially a non-probabilistic way of filling in the gaps in your nice probabilistic data points... – Spacedman Apr 10 '23 at 13:09
  • For the ESRI documentation, https://pro.arcgis.com/en/pro-app/latest/tool-reference/spatial-statistics/geographically-weighted-regression.htm doesn't mention anything about how the raster is created, only that it is an optional output you can look at. Is there somewhere else I should be looking? – ttalVlatt Apr 10 '23 at 16:18

0 Answers0