[R-sig-Geo] Merging shapefiles and csv

HallS sam_l_cruickshank at hotmail.com
Thu Jul 31 14:32:13 CEST 2014


Hi all,

I'm struggling to know how this will come across as my data is confidential.

Basically I have a shapefile (.shp) and a csv file while contain the same
regions (i.e.) a column which has the same information.  Using this link:
https://sites.google.com/site/eospansite/alobotips/spatial_r_tips/rshp_xls
I managed to get quite far but once I got to the writeOGR command, I get the
error
 Error in writeOGR(RSANHS, dsn = "C:/Users/Laptop/Documents/Rworkspace/",  : 
  number of objects mismatch

shape1 at data <- merge(shape1 at data,csv,by.x="RSA", 
+                           by.y="RSA", all.x=T, sort=F)
> 
> ###Checking it
> dim(shape at data)
[1] 1745    2
> dim(shape1 at data)
[1] 1747    5

This shows a discrepancy in two rows between the original shapefile and the
new merged one.  When I looked at the merged file in full, there were a
number of NA rows at the bottom where there was no corresponding data to the
shapefile.  I tried shape1 at data <- na.exclude(shape1 at data) and with na.omit,
and this did reduce the number of rows to 1690, but the problem persists.

Sorry if this is a really unhelpful question, I'm not sure how to do it when
data is confidential.



--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Merging-shapefiles-and-csv-tp7586839.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list