On Wed, 2 Jun 2010, christiaan pauw wrote:
Hallo Everybody
I have been using R for a while but I am new to using R on spatial
data. What I want to do seems fairly straightforward to me but for
some reason it doesn't seem to work even after reading a lot of help
files and mail threads. I want to read shapefile containing a town map
and subset it to contain only the polygons that correspond to a
certain field in the data frame. (i.e. selelct those houses in the
town for which I have some other data). I have a unique stand number
in both the dataframe and shapefile. Then in want to merge some
additional data from the dataframe and export back to a ESRI
shapefile.
I read the shapefiles with readOGR. The resultant object (called
SPbluegum) is a SpatialPolygonsDataFrame
class(SPbluegum)
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
I think where things go wrong is where I try to create a new object
that is a subset of the full town SPDF. My code is:
SPbluegumImP=SPbluegum[which(is.na(match(SPbluegum$PROPDESC,DF$Stand.Number_0))==FALSE),c(3,4,6)]
This works and can be plotted. class() reveals that this too is a
SpatialPolygonsDataFrame but it cannot be written with writeOGR. This
puzzles me since the error message reads:"unknown data type"
writeOGR(SPbluegumImp, dsn=paste(outdir,sep=""), layer="BluegumImpMap", driver="ESRI
Shapefile")
Error in writeOGR(SPbluegumImp, dsn = paste(outdir, sep = ""), layer =
"BluegumImpMap", :
unknown data type
Please show me where I go wrong
Please always report the version number of the package involved (usually
with sessionInfo() output). In this case, the error message formatting was
improved last year, so your rgdal is seriously out-of-date. Update first,
then if the error re-occurs, you'll know which variable in the data slot
of the object cannot be exported. More likely, it will be cast to another
representation in the updated rgdal.
Roger
best regards
Christiaan
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo