diff options
Diffstat (limited to 'scripts')
-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' ]}' | ||