Take the 2-minute tour ×
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 can display a shapefile in openlayers but I need to add some attribute data.

I can open the dbf file in excel but there is no save as option in excel to the updated file as a dbf.

What is the best way (or software to use) to add attribute data to my shapefile?

share|improve this question
Go back to an earlier version of Excel: MS removed the ability to write .dbf files with its latest version! :-( –  whuber Mar 6 '11 at 21:30
Open office and Quattro Pro can edit and save dbf files, just don't delete rows or move stuff around otherwise the index file won't allow things to match up. Use a commercial or open source gis for these tasks, editing cell values should cause no problem –  Dan Patterson Mar 6 '11 at 23:06
Well!!! And I thought my question was too simple for this site!! I have not had a chance to try any of the suggestions because I somehow trashed my geoserver and postgres softwares ... :-( So once I get my linux box back to 100% I'll get check out all the suggestions Thanks for taking the time to reply chris –  ChrisJ Mar 11 '11 at 6:11

10 Answers 10

up vote 16 down vote accepted

Using QGis you can edit your shapefile adding new columns and values. Just open the shapefile, go to Properties>Attributes and add new columns.

share|improve this answer
I didn't think of using QGIS because on my Linux box it (Copiapo) crashes when I click on "Fetch python plugin". Anyone knows if there's a fix for this? In the meantime I'll try adding the attributes with a widows version. –  ChrisJ Mar 6 '11 at 21:18
You could try to debug the problem the way Richard describes here: osgeo-org.1803224.n2.nabble.com/… –  underdark Mar 8 '11 at 18:10
QGIS allows you to add new columns, but populating the new column with data appears to be point-click-enter -- really inefficient! I suggest using R as in mdsummer's answer below. –  baha-kev Feb 23 '12 at 5:12

I've merged several shapefiles using MS Access. I needed to left join some data from other shapefile and it worked quite well. Also it was quick. However I guess not everyone has this software

share|improve this answer
I use either Access or some other form of SQL to manipulate data, usually. Just seems much easier for me to run a few queries. As mentioned before, you just have to watch the changing of actual database format, this is something that is best handled in the actual GIS software. –  MaryBeth Mar 7 '11 at 13:23

I usually use R (check mdsomners answer), but I would not recommend learning that if that is the only thing you want to do. I think the best approach would be using a GIS program, to create the fields, and then try editing them using openoffice.

More importantly, you should think whether you need to edit all the fields the attribute table directly, or if you can join other tables to it. The latter can be done in most GIS programs, eg SAGA GIS


share|improve this answer
Agreed. Every time I add/change data, I wonder if there is an easier way. –  MaryBeth Mar 7 '11 at 13:22

Use R with the foreign package to modify the DBF file:

dbfdata <- read.dbf("file.dbf", as.is = TRUE)
## add new attribute data (just the numbers 1 to the number of objects)
dbfdata$new.att <- 1:nrow(dbfdata)

## overwrite the file with this new copy
write.dbf(dbfdata, "file.dbf")

Or read the geometry and attribute data with the rgdal package (so you could modify the relationships as well and create a completely new shapefile):

## read "/path/to/files/filename.shp"
shp <- readOGR("/path/to/files/", "filename")  

## add new attribute data (just the numbers 1 to the number of objects)
shp$new.att <- 1:nrow(shp)

## write out to a new shapefile
writeOGR(shp, "/path/to/files/", "filename2")  
share|improve this answer

uDig has a nice tool called reshape, through which you can for example add attributes to a table: http://udig.github.io/docs/user/reference/Transform%20operation.html

Supported functions are those of the common query language: http://udig.github.io/docs/user/concepts/Constraint%20Query%20Language.html

share|improve this answer


  1. open the dbf in MS Excel 2007/10
  2. Make your changes (adding columns, populating data etc) and save as xls/xlsx
  3. Navigate to xls/xlsx location in ArcCatalog, right-click the worksheet and choose Export > To dBase (single)
  4. Rename the output dbf file as required
share|improve this answer

as andy pointed out in the link DARIAPRA refered you to, there is a Excel 2007 ADD-IN you might find useful - It allows you to save in the dbf format.you can find it on this website:


(As I have Excel 2003, I've never tried it, but I heard it was useful.

As for DBF manipulation outside ArcGIS - I've done it a few times. Sometimes it works, sometimes it doesn't. My two cents: If you can avoid the outside manipulation, avoid it. If you're dealing with a non-english language avoid it altogether - It tends to get all fumbled up when editing outside of ArcGIS).

share|improve this answer

Using QGIS is nice, and provides a solid interface for interacting with the DBF, but if you need to do something programmatically or just want tools to inspect shapefiles, I thought I'd mention a few other tools: I often use the basic features of shapelib for examining DBF files: it can add, create and modify both geometries and attributes, I often use dbfdump myshape.dbf to get a quick overview of the attribute values.

Another option if you're interested in programmatic control of a DBF is dbfpy, a python library (an an alternative to the nice foreign library mdsummer mentions). An example script for adding a column:

import dbfpy

db = dbf.Dbf("myshape.dbf", new=False)
# add a new character field named 'myfield'
db.addField(("myfield", "C", 15))

share|improve this answer

I would not recommend using OpenOffice - or a similar application - at all! Darren Cope commenting an answer to the question "DBF creation and manipulation without excel 2003" said:

it's that shapefiles get quite upset if you go and edit the .dbf in an 'outside' program

share|improve this answer
this isn't necessarily true: I've edited many shapefiles in OpenOffice and Excel without problems: you just need to be aware of the limitations of the format (column name lengths, data types, et cetera). –  scw Mar 7 '11 at 2:34
@scw: can you give any links to information about the format limitations? –  LarsH Aug 27 '14 at 16:18
The specific constraints vary by the particular software's use of the format, but the simplest restrictions are: 11 character field names, no special characters or spaces in field names, and stick to the core datatypes of DBF files (not esoteric things like 'memo' fields). For more details, see shapefile.py, the shapelib DBF API or this tome on xbase. –  scw Aug 27 '14 at 18:39

Open Office Calc allows you to read and write dbf files. But Lcasagrande's solution using QGIS should be safer.

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.