Hi all, 

I am trying to setup a geospatial CAR model to implement areal spatial 
smoothing (similar to Fig11.11 in "Applied Spatial Data Analysis with R" except 
without the beta term). 
I am using ESRI shapfiles downloaded from Census Ireland 
(http://www.cso.ie/en/census/census2011boundaryfiles/)
As some of the boundaries have changed over various census years, I need to 
join certain polygons - note these are adjacent polygons and I have used 
unionSpatial Polygons to try to do this. I am using a join_list of polygons 
that have changed and are to be joined - this is just a CSV file I made myself. 
The problem I am having is that my code is not joining the correct polygons and 
is in fact joining non-adjacent unrelated polygons. I can't figure out how to 
fix this.

My code looks like this: (FYI - EDdata contains a unique code for each polygon 
in a factor variable called GEOGID).

EDdata<-readOGR(".","Census2011_Electoral_Divisions_generalised20m",TRUE)
names(EDdata)
join_list<- read.csv("joins.csv", header=TRUE)

ED2<-merge(EDdata,join_list,by="GEOGID",all=TRUE)

# modify copied geogids as per join list
ED2$GEO<-as.character(ED2$GEOGID)
ED2$GEO[!is.na(ED2$Joined)]<-as.character(ED2$Joined[!is.na(ED2$Joined)])
ED2$GEOGID2<-as.factor(ED2$GEO)

# apply join function to polygons
EDdata$GEOGID2<-ED2$GEOGID2
EDpoly_joined <- unionSpatialPolygons(EDdata, EDdata$GEOGID2)


When I plot specific joined polygons they are not the adjacent ones I intended 
to join. As far as I can see - GEOGID and GEOGID2 match each other so I am a 
loss as to why the unionSpatialPolygons function appears to join to incorrect 
polygons.

FYI the join list looks like this (its longer than this but this should give 
you an idea).

                               Joined            variable       GEOGID
E01001                   E01001/01019     Sub1       E01001
E10001                         E10001         Sub1       E10001
E10004                         E10004         Sub1       E10004
E11001                   E11001/11026     Sub1       E11001
E11002                   E11002/11055     Sub1       E11002
E11003                   E11003/11092     Sub1       E11003



I cannot see where I am going wrong -I'd be very grateful for any 
assistance/advice.

Many thanks,

James
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to