Closed mfisher5 closed 4 years ago
Thanks so much for posting your first issue in this repo!
For anyone interested, the solution (from @briana-abrahms):
## create spatial points data frame
dat1_spdf <- SpatialPointsDataFrame(coords=group1_coords, data=group1_ids, proj4string = CRS("+init=epsg:4326"))
dat2_spdf <- SpatialPointsDataFrame(coords=group2_coords, data=group2_ids, proj4string = CRS("+init=epsg:4326"))
## generate utilization distributions
dat1_ud <- kernelUD(dat1_sp, grid=250, h=5000)
dat2_ud <- kernelUD(dat2_sp, grid=250, h=5000)
## convert to raster
ras1 <- raster(as(ud1,"SpatialPixelsDataFrame"))
ras2 <- raster(as(ud2,"SpatialPixelsDataFrame"))
## get 90% utilization distribution in raster object
ras1[ras1 >.90] <- 0; newras1 <- ras1/cellStats(ras1,sum)
ras2[ras2 >.90] <- 0; newras2 <- ras2/cellStats(ras2,sum)
## calculate Earth Mover's Distance
emd(newras1, newras2, gc=T)
Does anyone have experience working with the earth mover's distance to quantify spatial overlap, or is really into spatial data and would be willing to troubleshoot some weird results?
I'm using the
emd
function in themove
R package and have the R code running, but the distance measure isn't matching the map patterns... (example below, with earth mover's distance as EMD).I'm wondering if it has something to do with how I'm using utilization distributions as the input for
emd
?