# How to create generalized spatial weight matrix in R

5 messages
Open this post in threaded view
|

## How to create generalized spatial weight matrix in R

 Hi there, Dose any one tell me how to create a following generalized spatial weight matrix in R? w_{ij}=(l_{ij}/\sum_{j \in J}l_{ij})/d_{ij} (i=1,...,n) l_{ij} is length of shared  border of area i and area j. d_{ij} is centroid to centroid distance. I have enjoyed Moran's I with spdep package, but I found nb2listw() supported only binary spatial weight matrix and its standardized one. Other than R, which software can create generalized spatial weight matrix? Thank you in advance. -- Susumu Tanimura Dept. of Soico-environmental Medicine Institute of Tropical Medicine Nagasaki University, Japan
Open this post in threaded view
|

## How to create generalized spatial weight matrix in R

 Administrator On Wed, 3 Dec 2003, Susumu Tanimura wrote: > Hi there, > > Dose any one tell me how to create a following generalized spatial > weight matrix in R? > > w_{ij}=(l_{ij}/\sum_{j \in J}l_{ij})/d_{ij} (i=1,...,n) > > l_{ij} is length of shared  border of area i and area j. d_{ij} is > centroid to centroid distance. Centroid to centroid distance can be done in several software environments, including spdep - see function nbdists(). The difficulty is the boundary proportion, where you really need the arc topology to get at this cheaply. Just as a thought, how closely might the boundary length proportions from a Voronoi diagram match the measured proportions? Would that give an approximation? In general you may find that the binary representation is more parsimonious - it assumes less about a relationship we in any case do not know about. > > I have enjoyed Moran's I with spdep package, but I found nb2listw() > supported only binary spatial weight matrix and its standardized one. > See the glist argument to nb2listw() for the way to insert generalised weights, such as inverse distance. > Other than R, which software can create generalized spatial weight > matrix? On Windows, you could try GeoDa. Are there other suggestions, perhaps in Matlab? Roger > > Thank you in advance. > > -- > Susumu Tanimura > Dept. of Soico-environmental Medicine > Institute of Tropical Medicine > Nagasaki University, Japan > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo at stat.math.ethz.ch > https://www.stat.math.ethz.ch/mailman/listinfo/r-sig-geo> -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: Roger.Bivand at nhh.no Roger Bivand Department of Economics Norwegian School of Economics Helleveien 30 N-5045 Bergen, Norway
Open this post in threaded view
|

## How to create generalized spatial weight matrix in R

 Hi, Roger Bivand, It is very happy to get response from the author of spdep.  The idea to use the boundary length proportions from a Voronoi diagram instead of polygon borders is ingenious for me. Since  tripack or deldir seems to be related to voronoi diagram in current library of R, I am going to check these.  Do you have any other suggestions? > > I have enjoyed Moran's I with spdep package, but I found > > nb2listw() supported only binary spatial weight matrix and its > > standardized one. > > > See the glist argument to nb2listw() for the way to insert > generalised weights, such as inverse distance. I overlooked the glist. You gave us example in help, so I now know how to make generalized spatial wight matrix from any other list. > > Other than R, which software can create generalized spatial weight > > matrix? > > On Windows, you could try GeoDa. Ummm, I am a Linux user. Thank you.
 Administrator On Thu, 4 Dec 2003, Susumu [ISO-2022-JP] TANIMURA/$BC+B<(B $B?8(B wrote: > > It is very happy to get response from the author of spdep.  The idea > to use the boundary length proportions from a Voronoi diagram instead > of polygon borders is ingenious for me. > > Since  tripack or deldir seems to be related to voronoi diagram in > current library of R, I am going to check these.  Do you have any > other suggestions? No, I was thinking of tripack, but both could do it. They already contain topology (left-right neighbours I think) and computing the length of the boundaries must be simple. Perhaps someone with time on their hands and access to a range of shapes could see if this would be a workable or a very bad hack? It should handle Iowa quite well, shouldn't it? Can RArcInfo give us lengths of shared boundaries as a target from e00 and Arc binary polygons, say get.arcdata()? Cliff and Ord exclude the study area boundary - the proportion is of all internal boundaries per polygon, this probably needs to be looked at too? > > > > I have enjoyed Moran's I with spdep package, but I found > > > nb2listw() supported only binary spatial weight matrix and its > > > standardized one. > > > > > See the glist argument to nb2listw() for the way to insert > > generalised weights, such as inverse distance. > > I overlooked the glist. You gave us example in help, so I now know how > to make generalized spatial wight matrix from any other list. > > > > Other than R, which software can create generalized spatial weight > > > matrix? > > > > On Windows, you could try GeoDa. > > Ummm, I am a Linux user. Any others with experience of benefits or otherwise of using generalised weights? Roger > > Thank you. > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo at stat.math.ethz.ch > https://www.stat.math.ethz.ch/mailman/listinfo/r-sig-geo> -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: Roger.Bivand at nhh.no Roger Bivand Department of Economics Norwegian School of Economics Helleveien 30 N-5045 Bergen, Norway
 > Perhaps someone with time on their hands and > access to a range of shapes could see if this would be a workable or a > very bad hack? It should handle Iowa quite well, shouldn't it? Can > RArcInfo give us lengths of shared boundaries as a target from e00 and Arc > binary polygons, say get.arcdata()? Cliff and Ord exclude the study area > boundary - the proportion is of all internal boundaries per polygon, this > probably needs to be looked at too? >  Latest version of PostGIS with GEOS can calculate length of two boundary-shared polygons.  PostGIS's utilities can import from and export to shapefiles.  R can use these functions via RODBC or maybe Rdbi.  I'll show following example using RODBC.   w<-c()   tbl<-sqlQuery(channel,"select id  from columbus")   for(i in tbl$id){ tbl<-sqlQuery(channel,paste("select id, length(intersection(the_geom,(select the_geom from columbus where id =", i,"))) from columbus")) w<-cbind(w,tbl$length)   } For intersections of same geometries, this results are original geometry and lengths are 0 (since length function calculate only length of linestring, not (multi-)polygon).   Regards.