Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 3 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 '15 at 22:14

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 '15 at 4:50

As already mentioned, shapefiles have a field name character limit of 10 characters. writeOGR meets this requirement by changing the field headings by using some algorithm that prioritizes what characters to remove when there is a field name that exceeds the limit. I'm not sure how it works, but it seems to shorten field names in strange and unpredictable ways. Here's my work around. Using strtrim() and setting the character length to 10 will truncate the field names to 10 characters more predictably than writeOGR's automation.

One issue is that you might have is if you have fieldnames that are identical for the first 10 characters, but I've never had this problem.

I apply this every time I export a shapefile, just in case.


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

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

names(points) <- strtrim(names(points),10)

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

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.