diff options
author | typebrook <typebrook@gmail.com> | 2019-10-24 21:17:58 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-10-24 21:17:58 +0800 |
commit | 687521c6a1d401ba03abdf24b0de0ab3032aa2ec (patch) | |
tree | 7e98d45221f590e268f393e9ba9c0e3a3909d100 /scripts/csv2geojson | |
parent | 4f0dcf99ff761ad2acae56ad1b2c1952db79ec24 (diff) | |
parent | 005b07bd7e66248692bb4ac6f7eab1fe33fe2016 (diff) |
Merge remote-tracking branch 'origin/dev' into dev
Diffstat (limited to 'scripts/csv2geojson')
-rwxr-xr-x | scripts/csv2geojson | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/csv2geojson b/scripts/csv2geojson new file mode 100755 index 0000000..90e6141 --- /dev/null +++ b/scripts/csv2geojson | |||
@@ -0,0 +1,16 @@ | |||
1 | #! /bin/bash | ||
2 | |||
3 | echo -------------- | ||
4 | head -1 $1 | sed 's/,/ /g' | awk '{for (i=1; i<=NF; i++) printf $i "_" i " "; print ""}' | ||
5 | echo -------------- | ||
6 | echo | ||
7 | |||
8 | read -p "Number of latitude column: " lat_col | ||
9 | read -p "Number of longitude column: " lon_col | ||
10 | |||
11 | sed 's/[^,]*/"\0"/g' $1 |\ | ||
12 | sed 's/.*/[\0]/g' |\ | ||
13 | sed '1d' |\ | ||
14 | jq --arg LAT_INDEX $lat_col LON_INDEX $lon_col '. | {"type": "Feature", "properties": {}, "geometry":{ "type": "Point", "coordinates": [(.[LAT_INDEX] | tonumber), (.[LON_INDEX] | tonumber)] } }'|\ | ||
15 | jq -s '{"type": "FeatureCollection", "features": .}' | ||
16 | #awk '{for (i=1; i<= NF; i++) if (i != 2 && i != 3) printf $i " "; printf [ " " {; print ""}' test' ]}' | ||