Adding Attribute data to shapefile?
Using QGIS you can edit your shapefile adding new columns and values. Just open the shapefile, go to Properties>Attributes and add new columns.
In newer versions of QGIS (2.x), 'Attributes' is called 'Fields'
Use R
with the foreign
package to modify the DBF file:
library(foreign)
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):
library(rgdal)
## 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")
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