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 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

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
You can also list the field names using ogrinfo -so inputfile.shp inputfile – Mike T Nov 12 '14 at 2:47
A side note: this method only works when transforming shapefiles. For example if using GeoJSON data format you need to first convert it to a shapefile, then do another transformation using the -sql flag. – clhenrick Sep 4 '15 at 13:22

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.