Dear r-sig-geo, I am having trouble exporting an sp object created in R using writeOGR. Below is the code I am using, basically it creates a regular grid to cover a point data set opened using readShapePoints. I then convert the spatialpoints to polygons and then finally to a SpatialPolygonsDataFrame. I would now like to export this sp data set as a shapefile so that I can add some attributes to it. Unfortunately I receive the following error each time I try to run the export,
> poly<-readShapePoints("Poly_one_pts.shp", proj4string=CRS("+proj=tmerc +south > +ellips=WGS84 +datum=WGS84 +lon_o=31 +k_0=1 +units=m +no_defs")) > grd<-spsample(poly,cellsize=c(4,4),type="regular") > grd<-as(as(as(grd,"SpatialPixels"),"SpatialPolygons"),"SpatialPolygonsDataFrame") > tp<-tempdir() > writeOGR(grd,tp,"grd",driver="ESRI Shapefile",verbose = FALSE) Error in writeOGR(grd, tp, "grd", driver = "ESRI Shapefile", verbose = FALSE) : NULL NULL unknown data type An export of poly runs fine but it seems when I try to export grd it is an unknown data type. Both classes seem to be similar and writeOGR should be able to export both data sets. > class(poly) [1] "SpatialPointsDataFrame" attr(,"package") [1] "sp" > class(grd) [1] "SpatialPolygonsDataFrame" attr(,"package") [1] "sp" Any help on this issue would be greatly appreciated. Many thanks and kind regards, Wesley Wesley Roberts MSc. Researcher: Earth Observation Natural Resources & the Environment (NRE) CSIR Tel: +27 (0)21 888-2490 Fax: +27 (0)21 888-2693 "To know the road ahead, ask those coming back." - Chinese proverb -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks Transtec Computers for their support. _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo