Skip to main content

Questions tagged [spdep]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
48 views

Are there alternatives to this construction of a minimum spanning tree of a raster for the SKATER algorithm?

This could be seen as a continuation of this question where the top accepted answer uses the spedp library in R in order to generate contiguous clusters of a raster image with multivariate data. In ...
Phil's user avatar
  • 13
0 votes
1 answer
90 views

spdep::localmoran How to access classified cluster values?

I am trying to get a LISA cluster map similar to this one, eg showing the 'High-high', 'Low-Low'.. cllassified values. But, I can't figure out how to extract this classifications from the ...
maycca's user avatar
  • 3,376
0 votes
1 answer
83 views

Combine neighbors lists while estimating a spatial lag model with multiple time periods with R

I am trying to estimate a spatial lag model for a dataset of U.S. school districts with four years of data. The issue is that the dimensions of the school districts change every year (i.e. the ...
ModalBro's user avatar
  • 111
1 vote
1 answer
102 views

poly2nb {spdep} how identify if two cities are neighbours

I'm trying to identify if two cites are neighbours using spdep::poly2nb function, but it returns a list with numbers that i can't understand. For example, shp_ce <- rgdal::readOGR(dsn = "...
walves's user avatar
  • 113
0 votes
0 answers
58 views

Spatial neighbors to voxels for R-INLA

I am working on an fMRI dataset that I want to analyse using a Bayesian spatial model in R-INLA. I extracted the coordinates for all these voxels. (See the image to get an impression one such a ...
BasMts's user avatar
  • 1
0 votes
2 answers
421 views

Applying Moran's I across columns

So I find myself needing to apply global Moran's I across ~20 variables (as in ~20 instances of univariate autocorrelation for each variable, not attempted multivariate spatial autocorrelation). I'm ...
efor027's user avatar
1 vote
2 answers
670 views

Calculate sum/average of variable within each group of neighboring counties using R

I am trying to calculate the sum and/or average value of a variable for each group of neighboring counties in the US. I realized this needs at least two steps: For every county, find the set of ...
wbmason88's user avatar
4 votes
1 answer
649 views

KNN for spatial data and two sets of coordinates

I'm trying to estimate an average value of distances to K nearest neighbors. I have two sets of coordinates and I'm trying to estimate the average distance from each point in one set of coordinates to ...
T72's user avatar
  • 43
1 vote
1 answer
818 views

bivariate LISA in R [closed]

I am new to R. I am interested to estimate Moran's I result. Specifically, a map of the bivariate spatial correlation (bivariate LISA) in R using spdep and ggplot2 package. I have points data over ...
user avatar
2 votes
1 answer
320 views

Moran's I statistical significance with spdep mc.moran function

I would like to obtain Moran's I estimation together with its p-value from a raster data layer --which has na value-- including a figure showing the simulation distribution by mean of spdep::mc.moran()...
Gab's user avatar
  • 413
1 vote
1 answer
839 views

Ignore NAs when getting lagged values in spdep

I'm trying to replicate a study on gentrification of neighbourhoods and I'm dealing with some missing values of mean rent and selling prices for some neighbourhoods. Since these values are very ...
marcbosch's user avatar
  • 157
5 votes
1 answer
933 views

How to assign a neighbour status to unlinked polygons

This question is, in part, a follow up to: https://stackoverflow.com/questions/57269254/how-to-impute-missing-neighbours-of-a-spatial-weight-matrix-queen-contiguity I have a .shp similar in structure ...
richard.turner's user avatar
1 vote
1 answer
1k views

Simple KNN for spatial data

I try to find an example to estimate an average value associated to a coordinate, with K nearest neighbors. I found this very help tutorial regional smoothing. This code can find the k nearest ...
John Smith's user avatar
0 votes
0 answers
605 views

Problems with adjacency matrix with poly2nb in R

I am working with a shapefile of Ohio precincts, with the hope of performing areal regression models (probably BYM2). To build the adjacency matrix, I used poly2nb from the spdep package. As a double-...
St4096's user avatar
  • 1
1 vote
0 answers
28 views

On the calculus of joint-count test on no-full grid

I have a data points of presence-absence records and I want to perform joint-count test as it was suggested in the post https://gis.stackexchange.com/a/388939/178392 by calculating it on a grid (...
user7666's user avatar
1 vote
0 answers
214 views

On the calculus of the variable "autocov" from spdep package

I’m facing a spatial autocorrelation problem and I want to calculate the «  autocov» covariate through the function autocov_dist from spdep package. The problem is when I defined the neighborhood ...
user2300's user avatar
2 votes
1 answer
320 views

Spatial neighbors in ggplot2

I'm trying to make a space plot with ggplot() as indicated here, but I'm having trouble using the nb2lines() function. .shp files are here Error in if (!is.na(projargs) && !nzchar(projargs)) ...
cdcarrion's user avatar
  • 123
3 votes
1 answer
2k views

Moran's I z-value in spdep

I wish to incrementally find the neighbour distance which maximises Moran's I test statistic. I have read that the I values are not comparable across varying spatial weight matrices but that the z-...
syre's user avatar
  • 407
2 votes
1 answer
3k views

poly2nb {spdep} not identifying neighbours correctly

I am trying to do some spatial generalised linear mixed models for areal unit data with the CARBayes package. As part of this, I need to identify the polygon neighbours into a neighbour list using ...
hclutter's user avatar
0 votes
1 answer
425 views

How to convert coordinates to shapefile with R package's dataset?

I need construct spatial weight matrix for data which syear=1995 (house$s1995==1)in housedataset in spdeppackage,So I tried writeOGR function as the link suggeust to get shapefile enter link ...
Yuki's user avatar
  • 15
-1 votes
1 answer
242 views

The slot for "plotOrder" comes up as 1 instead of a vector with length specific to my data

My goal is to find neighbors from my SpatialPolygons object using the poly2nb() command from the sp package in R. This is my code thus far: p <- s_gis %>% select(long, lat) %>% ...
Lathan's user avatar
  • 3
0 votes
1 answer
512 views

How do you find the appropriate spatial weight to use for a spatial analysis? [closed]

I am currently about to run a spatial regression (OLS, Lag, Error etc) for my dataset. My dataset contains 1000 randomly generated points throughout the utilisation distribution for my animals (so, ...
Redskies421's user avatar
3 votes
0 answers
726 views

LISA (local indicators of spatial association) p values in R versus in Geoda

When calculating LISA statistics in GeoDa versus using the localmoran() function in spdep, the I values are nearly the same, but the p values can be quite different. I know the two programs calculate ...
user2905280's user avatar
4 votes
1 answer
12k views

Merge spatial and non-spatial data and create SpatialPolygonsDataFrame in r

I am trying to merge non-spatial data (data frame in R) and spatial data (SpatialPolygonsDataFrame in R) and eventually create the merged file in SpatialPolygonsDataFrame form. In specific, I ...
Emily's user avatar
  • 149
3 votes
1 answer
537 views

Out-of-Sample predictions with spdep::sarlm

I am trying to make an out of-sample-prediction for spatial data using the spdep package. The documentation claims that this should be possible. However, I do not understand how it works. In ...
Alex's user avatar
  • 325
4 votes
0 answers
709 views

Spatial weight matrix with boundary effects in R?

I need some help to finalize code for a spatial weight matrix that uses a nearest neighbor definition within regions, but does not allow neighbors from across a political border. For example, ...
Zonderpaard's user avatar
1 vote
0 answers
701 views

Using errorsalm() from spdep with multilevel data?

I have a dataset that has multiple observations per county, and I am interested in estimating the effect of a county-level variable on individual-level outcomes. I would like to account for adjacency ...
Prachi Sanghavi's user avatar
8 votes
3 answers
2k views

Calculating spatial lags per year in R

At the moment I am having some difficulties with calculating a spatial lag in R. I know how to calculate the lag in space-wide format but am unable to do it in long form, i.e. have repeated ...
horseoftheyear's user avatar