Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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