[R-sig-Geo] How to create generalized spatial weight matrix in R

Hisaji Ono hi_ono2001 at ybb.ne.jp
Thu Dec 4 09:12:12 CET 2003


> 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.




More information about the R-sig-Geo mailing list