Skip to content

Commit 7803895

Browse files
committed
Merge branch 'n0rdlicht-master'
2 parents 4da8d2e + d718f18 commit 7803895

File tree

10 files changed

+10891
-4422
lines changed

10 files changed

+10891
-4422
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
downloads/*.zip filter=lfs diff=lfs merge=lfs -text
1+
downloads/swissBOUNDARIES3D.zip filter=lfs diff=lfs merge=lfs -text

Makefile

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ CKAN_Endpoint = "https://opendata.swiss/api/3/"
22
# action/package_show?id=
33
PKG_ID = swissboundaries3d_gemeindegrenzen
44
FILE_NAME = swissBOUNDARIES3D
5+
GMD = gemeinden-collected.gpkg
56

67
.PHONY: all
78

@@ -11,29 +12,35 @@ data/gemeinden.json: data/gemeinden.csv
1112
mkdir -p $(dir $@)
1213
cat $< | node_modules/.bin/csvtojson > $@
1314

14-
data/gemeinden.csv: build/gemeinden-clean.gpkg
15+
data/gemeinden.csv: data/gemeinden.geojson
1516
mkdir -p $(dir $@)
16-
ogr2ogr -f CSV $@ $<
17-
sed -i.bkp 's/ [(][A-Z][A-Z][)]//g' $@
17+
ogr2ogr -lco STRING_QUOTING=IF_NEEDED -f CSV $@ $<
1818

19-
build/gemeinden-clean.gpkg: build/gemeinden.gpkg
19+
data/gemeinden.geojson: build/gemeinden-clean.gpkg
2020
mkdir -p $(dir $@)
21-
ogr2ogr -f GPKG $@ $< -sql 'select distinct `gemeinde.BFS_NUMMER`,`gemeinde.NAME`,`kanton.KUERZEL`,`kanton.NAME` from gemeinde'
21+
ogr2ogr -f GeoJSON -t_srs "EPSG:4326" $@ $<
22+
sed -i '' 's/ [(][A-Z][A-Z][)]//g' $@
23+
24+
build/gemeinden-clean.gpkg: build/gemeinden-collected.gpkg
25+
mkdir -p $(dir $@)
26+
ogr2ogr -f GPKG $@ $< -sql 'select distinct `gemeinde.BFS_NUMMER`,`gemeinde.NAME`,`kanton.KUERZEL`,`kanton.NAME`, geom from gemeinde WHERE `gemeinde.BFS_NUMMER` < 9000 OR `gemeinde.BFS_NUMMER` > 9999 ORDER BY `gemeinde.BFS_NUMMER` ASC'
2227

2328
build/gemeinden.gpkg: src/kantone.csv build/kantone.csv
24-
ogr2ogr -f GPKG -sql "select gemeinde.*, kanton.* from swissBOUNDARIES3D_1_3_TLM_HOHEITSGEBIET AS gemeinde left join '$<'.kantone as kanton on gemeinde.KANTONSNUM = kanton.KANTONSNUM WHERE gemeinde.ICC = 'CH'" $@ downloads/$(PKG_ID)/BOUNDARIES_2020/DATEN/swissBOUNDARIES3D/SHAPEFILE_LV95_LN02/swissBOUNDARIES3D_1_3_TLM_HOHEITSGEBIET.shp -nln "gemeinde"
29+
ogr2ogr -f GPKG -sql "select gemeinde.*, kanton.* from swissBOUNDARIES3D_1_3_TLM_HOHEITSGEBIET AS gemeinde left join '$<'.kantone as kanton on gemeinde.KANTONSNUM = kanton.KANTONSNUM WHERE gemeinde.ICC = 'CH'" $@ downloads/$(PKG_ID)/swissBOUNDARIES3D_1_3_TLM_HOHEITSGEBIET.shp -nln "gemeinde"
2530
# ogr2ogr -f GPKG $@ downloads/$(PKG_ID)/BOUNDARIES_2020/DATEN/swissBOUNDARIES3D/SHAPEFILE_LV95_LN02/swissBOUNDARIES3D_1_3_TLM_HOHEITSGEBIET.shp
2631

2732
build/kantone.csv: downloads/$(FILE_NAME).zip
2833
mkdir -p $(dir $@)
2934
mkdir -p $(dir $<)$(PKG_ID)/
3035
unzip -n $< -d $(dir $<)$(PKG_ID)/
31-
ogr2ogr -f CSV -dialect sqlite -sql "select distinct KANTONSNUM, NAME, HERKUNFT, REVISION_J, REVISION_M from swissBOUNDARIES3D_1_3_TLM_KANTONSGEBIET ORDER BY KANTONSNUM ASC" $(dir $@)/kantone.csv $(dir $<)$(PKG_ID)/BOUNDARIES_2020/DATEN/swissBOUNDARIES3D/SHAPEFILE_LV95_LN02/swissBOUNDARIES3D_1_3_TLM_KANTONSGEBIET.shp
36+
ogr2ogr -f CSV -dialect sqlite -sql "select distinct KANTONSNUM, NAME, HERKUNFT, REVISION_J, REVISION_M from swissBOUNDARIES3D_1_3_TLM_KANTONSGEBIET ORDER BY KANTONSNUM ASC" $(dir $@)/kantone.csv $(dir $<)$(PKG_ID)/swissBOUNDARIES3D_1_3_TLM_KANTONSGEBIET.shp
3237

33-
# downloads/%.zip:
34-
# mkdir -p $(dir $@)
35-
# curl http://data.geo.admin.ch/ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill/data.zip -L -o $@.download
36-
# mv $@.download $@
38+
downloads/%.zip:
39+
mkdir -p $(dir $@)
40+
cd downloads
41+
curl https://data.geo.admin.ch/ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill/shp/2056/ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill.zip -L -o $@.download
42+
# curl http://data.geo.admin.ch/ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill/data.zip -L -o $@.download
43+
mv $@.download $@
3744

3845
clean:
3946
rm -rf build/

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
> Background and data processing: [github.com/smartuse/toolbox-municipalities](https://github.com/smartuse/toolbox-municipalities)
88
9-
This repository compiles tools to generate a Frictionless Data compliant Datapackage of the current Swiss municipalities in CSV and JSON formats.
9+
This repository compiles tools to generate a Frictionless Data compliant Datapackage of the current Swiss municipalities in CSV, JSON and GeoJSON formats.
1010

1111
To add new datasets or make modifications, please visit our [GitHub repository](https://github.com/smartuse/toolbox-municipalities) and contact us via Issues or Pull Request.
1212

@@ -32,8 +32,9 @@ Now, clone this reposiory and run `make`
3232

3333
The downloads, build and the data folders should now be populated with processes files.
3434

35-
* `data/gemeinden.csv` contains a list of municipalities
36-
* `data/gemeinden.json` is the same list as nested JSON
35+
* `data/gemeinden.geojson` is generated first
36+
* `data/gemeinden.csv` is derived from the `geojson`
37+
* `data/gemeinden.json` is then derived from the `csv` version
3738

3839
## Push to Datahub
3940

@@ -51,7 +52,7 @@ Then you can update the list by
5152

5253
## Author
5354

54-
Thorben Westerhuys, SmartUse GmbH
55+
Thorben Westerhuys, cividi GmbH
5556

5657
## Datapackage
5758

0 commit comments

Comments
 (0)