summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xscripts/csv2geojson16
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
3echo --------------
4head -1 $1 | sed 's/,/ /g' | awk '{for (i=1; i<=NF; i++) printf $i "_" i " "; print ""}'
5echo --------------
6echo
7
8read -p "Number of latitude column: " lat_col
9read -p "Number of longitude column: " lon_col
10
11sed 's/[^,]*/"\0"/g' $1 |\
12sed 's/.*/[\0]/g' |\
13sed '1d' |\
14jq --arg LAT_INDEX $lat_col LON_INDEX $lon_col '. | {"type": "Feature", "properties": {}, "geometry":{ "type": "Point", "coordinates": [(.[LAT_INDEX] | tonumber), (.[LON_INDEX] | tonumber)] } }'|\
15jq -s '{"type": "FeatureCollection", "features": .}'
16#awk '{for (i=1; i<= NF; i++) if (i != 2 && i != 3) printf $i " "; printf [ " " {; print ""}' test' ]}'