>From what I can gather with your code:
- check the result of your Paste command and make sure it is a valid path.
- Also make sure your object a (in writePolyShape(a,Dir)) is a
SpatialPolygonsDataFrame object, it seems to me that it is a plain data
frame. You can convert it with the sp package command
SpatialPolygonsDataFrame.

Hope it helps

2011/1/31 Jaime Burbano Girón <jaimebg27@gmail.com>

> Hi everybody, I am new using R with vector spatial data. I want to export 1
> or a few polygons from my shapefile which has 421 polygons with the
> function
> "writePolyShape" from library maptools, but I get the following error:
>
> *Error en write.dbf(df, paste(file, ".dbf", sep = ""), factor2char =
> factor2char,  :  unable to open file*
>
> This is the code:
> *
> Cuencas=readShapePoly("D:/Modelamiento_Hidrológico/Capas
> Adicionales/Watershed_Final.shp")
> A.Cuencas=as(Cuencas,"data.frame")
> a=Cuencas[Cuencas$HydroID<151838,]
> Dir=paste("D:/Modelamiento_Hidrológico/Watersheds",A.Cuencas[1,2],sep="/")
> writePolyShape(a,Dir)



> *
>
> I´ve tried exporting just 1 polygon, 2 or more, but the error is always the
> same. I appreciate your help.
>
> Thanks a lot in advance and my best regards.
>
> --
> Jaime Burbano Girón
> Departamento de Ecología y Territorio
> Pontificia Universidad Javeriana
> Bogotá - Colombia
> (571) 3208320 Ext. 4836
>
>        [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>

	[[alternative HTML version deleted]]

