Skip to content

Instantly share code, notes, and snippets.

@capooti
Created August 20, 2014 10:03
Show Gist options
  • Save capooti/f1f272eeefc1ceb89007 to your computer and use it in GitHub Desktop.
Save capooti/f1f272eeefc1ceb89007 to your computer and use it in GitHub Desktop.
Rename shapefile field names from uppercase to lowercase using OGR
declare -a fields=("ROADID" "SOURCEID" "NOTES" "ONME" "RTENME" "NTLCLASS" "FCLASS" "NUMLANES" "SRFTPE" "SRFCOND" "SRFPREP" "ISSEASONAL" "CURNTPRAC" "GNRALSPEED" "GDWTHRPRAC" "BDWTHRPRAC" "SHAPE_LENG" "ADM0_CODE" "ADM0_NAME" "CONTINENT" "REGION")
shp="was_trs_roads_wfp"
for f in "${fields[@]}"
do
lf=$(echo $f | awk '{print tolower($0)}')
echo $lf
ogrinfo $shp.shp -sql "ALTER TABLE $shp RENAME COLUMN $f TO $lf"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment