-
Notifications
You must be signed in to change notification settings - Fork 6
/
split.sh
executable file
·39 lines (32 loc) · 1.48 KB
/
split.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
set -e
export OGR_WKT_PRECISION=9
TMP="${1}"
function split() {
shp="$1"
enota="$2"
descriptionCollection="$3"
# descriptionSingle="$4"
shpFile=$(find "${TMP}" -name "$shp.shp")
DIRNAME=$(dirname "$shpFile")
BASENAME=$(basename "$shpFile" .shp)
echo "${descriptionCollection}: Extracting ${enota} from ${shp}..."
mkdir -p "data/${shp}"
SHAPE_ENCODING=CP1250 ogr2ogr -t_srs "EPSG:4326" \
-f "CSV" "data/${shp}/${BASENAME}_${enota}.csv" "${DIRNAME}" \
-sql "SELECT * FROM ${BASENAME} WHERE ENOTA='${enota}' ORDER BY ${BASENAME}_MID" -dialect sqlite \
-lco WRITE_BOM=YES -lco STRING_QUOTING=IF_NEEDED
SHAPE_ENCODING=CP1250 ogr2ogr -t_srs "EPSG:4326" \
-f "GeoJSON" "data/${shp}/${BASENAME}_${enota}.geojson" "${DIRNAME}" \
-sql "SELECT * FROM ${BASENAME} WHERE ENOTA='${enota}' ORDER BY ${BASENAME}_MID" -dialect sqlite \
-lco RFC7946=YES -lco WRITE_BBOX=YES -mapFieldType Date=String \
-nln "${BASENAME}_${enota}" -lco DESCRIPTION="${descriptionCollection}"
}
split VDV VE "Državnozborske volilne enote" "Državnozborska volilna enota"
split VDV VO "Državnozborski volilni okraji" "Državnozborski volilni okraj"
split VDV VD "Državnozborska volišča" "Državnozborsko volišče"
split VLV LE "Lokalne volilne enote" "Lokalna volilna enota"
split VLV LV "Lokalna volišča" "Lokalno volišče"
split ODO CM "Mestne četrti" "Mestna četrt"
split ODO CK "Krajevne skupnosti" "Krajevna skupnost"
split ODO CV "Vaške četrti" "Vaška četrt"