Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm currently using the following script to add some attribute data from a table to lots of individual shapefiles:

specieslist <- read.csv("SpeciesList1.txt", header=F)
attdata <- read.table("TestAtt.csv", sep = ",", header=T)
for (n in 1:dim(specieslist)[1]) 
speciesname <- specieslist[n,1]
shp <- readOGR("Mesoamerica_modified_polygons", speciesname)
writeOGR(shp, "PolygonsV2", speciesname, driver="ESRI Shapefile")

I get the following warning(s) at the end:

1: In writeOGR(shp, "PolygonsV2", speciesname, driver = "ESRI Shapefile") :
Field names abbreviated for ESRI Shapefile driver

When viewing the attribute table of the shapefiles after this process, the Field name has been shortened to 'ENGL_', but I want it to stay as 'ENGL_NAME'. Is there a way to turn this abbreviating off?

Any help much appreciated.

share|improve this question
Are any of the fieldnames in the shapefile > 10 characters? Looks like a bug in the R bindings to me. – geographika Aug 2 '12 at 12:04
Hi there, I just re-ran the script and now it isn't abbreviating. I'm not sure what's changed to cause this though... – JPD Aug 2 '12 at 12:27

3 Answers 3

up vote 2 down vote accepted

You can't, it's a shapefile issue. See under 'Creation Options'

share|improve this answer
so it is not an issue of writeOGR? Is it actually issue of the format? – Tomas Dec 2 '14 at 17:34
Correct. dbf column name lengths are limited. Another format, for example sqlite/spatialite would not truncate the names (there are very large limits in sqlite, but many orders of magnitude above 10). – kyle Dec 4 '14 at 16:48
Well, there is a difference between normal abbreviation of column names when writing to dbf and what writeOGR is doing there! writeOGR is crippling even field names shorter than 10. My examples: My R-column name "ora_nachweis_id" becomes "or_nch_" while writeSpatilaPolygon does the normal abbreviation -> "ora_nachwe". Even my variable "LblColor" (8 characters !) becomes "LblColr". – Bernd V. Dec 4 '14 at 19:09
Are there similar column names in the db/data structure? I couldn't replicate with ogr2ogr and a sqlite db with those names. If you can provide a sample I could look further, or perhaps the R bindings are causing issues. – kyle Jan 13 at 22:14

Just truncate the field names before writing your shapefile using strtrim(). So simple.

table <- data.frame(X_Coordinates = runif(10)*1000, 
                    Y_Coordinates = runif(10)*1000, 
                    StupidLongFieldNameForData = runif(10))

points <- SpatialPointsDataFrame(SpatialPoints(table), data = table)


writeOGR(points, "OutputDirectory", "Points", "ESRI Shapefile")
share|improve this answer

Your 'ENGL_NAME' shouldn't be abbreviated at all (less than 10 characters), but writeOGR has its own will, it seems.

Instead of

writeOGR(shp, "PolygonsV2", speciesname, driver="ESRI Shapefile")

you might try

currdir <- getwd() #store your current working directory
setwd(paste(currdir,"PolygonsV2",sep="/")) #switch to your desired folder

writeSpatialShape(shp, speciesname) # write shapefile

setwd(currdir) #switch back to parent folder

As writeSpatialShape seems not have a parameter for the destination, I found this workaround switching the working directory back and forth.

The other problem there is, that it does't produce a .prj-file, but thats a minor problem, compared to destroyed field names.

Waiting for the times when +*#-!(/ ESRI Shapefile format is finally dead and replaced by ... well?

share|improve this answer
+1 Great work-around! – Aaron Jul 9 at 4:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.