diff options
-rwxr-xr-x | scripts/csv2geojson | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/scripts/csv2geojson b/scripts/csv2geojson index 49ed0c9..90e6141 100755 --- a/scripts/csv2geojson +++ b/scripts/csv2geojson | |||
@@ -1,7 +1,7 @@ | |||
1 | #! /bin/bash | 1 | #! /bin/bash |
2 | 2 | ||
3 | echo -------------- | 3 | echo -------------- |
4 | head -1 $1 | sed 's/,/ /g' | 4 | head -1 $1 | sed 's/,/ /g' | awk '{for (i=1; i<=NF; i++) printf $i "_" i " "; print ""}' |
5 | echo -------------- | 5 | echo -------------- |
6 | echo | 6 | echo |
7 | 7 | ||
@@ -11,5 +11,6 @@ read -p "Number of longitude column: " lon_col | |||
11 | sed 's/[^,]*/"\0"/g' $1 |\ | 11 | sed 's/[^,]*/"\0"/g' $1 |\ |
12 | sed 's/.*/[\0]/g' |\ | 12 | sed 's/.*/[\0]/g' |\ |
13 | sed '1d' |\ | 13 | sed '1d' |\ |
14 | jq '. | {"type": "Feature", "properties": {}, "geometry":{ "type": "Point", "coordinates": [(.[-1] | tonumber), (.[-2] | tonumber)] } }'|\ | 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": .}' | 15 | jq -s '{"type": "FeatureCollection", "features": .}' |
16 | #awk '{for (i=1; i<= NF; i++) if (i != 2 && i != 3) printf $i " "; printf [ " " {; print ""}' test' ]}' | ||