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 need to rename the field names (attributes) in a shapefile. Is there an easy way to do this from the command line?

share|improve this question
add comment

1 Answer

You can use the ogr2ogr utility which is packaged with the gdal command line tools. Use the -sql option as follows:

ogr2ogr outputfile.shp inputfile.shp -sql "SELECT oldfield1 AS newfield1, oldfield2 AS newfield2 from inputfile"

As an added bonus, you can convert the data into a different format at the same time, or filter your data by specifying a where clause. Note that you will need to specify all output fields if you use this method (any fields not included in the SELECT statement will be dropped from the output file).

share|improve this answer
add comment

Your Answer

 
discard

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.