[R-sig-Geo] Conversion of a SpatialPolygonsDataFrame into a ESRI file

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Mar 22 00:57:53 CET 2012


On Wed, Mar 21, 2012 at 10:29 PM, Francis Markham <fmarkham at gmail.com> wrote:
> I've experienced the same problem. How would one go about submitting a bug
> report to rgdal on this?

 How is it a bug with rgdal? I've just had a look for the spec of
dBase files, and the only one I can find:

http://www.dbase.com/Knowledgebase/INT/db7_file_fmt.htm

 says the field name is "32 bytes 	Field name in ASCII (zero-filled)."
I just tried R with rgdal and it could write and read quite happily a
SpatialPointsDataFrame with dots in the field names. Try this:

library(sp)
library(rgdal)
df = data.frame(x=runif(10),y=runif(10),zz=runif(10))
coordinates(df)=~x+y
writeOGR(df,".","junk","ESRI Shapefile")

names(df)="z.z"
writeOGR(df,".","junk2","ESRI Shapefile")

 - both work for me, and QGIS can read them in, and R can read them
back into fresh sessions. If anything its a bug in ArcGIS, but without
a good description of the failing shapefile (exact item names for
starters) we're guessing.

 It might be *non-ascii* field names, which aren't covered by the spec
I just read but might be by some other extension. You can handle this
in R by setting the Encoding of the field names explicitly.

Barry



More information about the R-sig-Geo mailing list