Cleaned up province segmentation
This commit is contained in:
1 parent
d56eb3a700
commit
650d596f03
22 files changed
+20297
-9417
No files matched your search
@@ -15,7 +15,7 @@ using image processing.
|
||||
|
||||
Results
|
||||
|
||||
* [data/dialect_regions.geojson](data/dialect_regions.geojson)
|
||||
* [data/frysian_dialect_regions.geojson](data/frysian_dialect_regions.geojson)
|
||||
|
||||
### Group recordings to Frysian dialect regions
|
||||
|
||||
@@ -30,3 +30,29 @@ Results
|
||||
* [data/free_speech_recordings_by_dialect.xlsx](data/free_speech_recordings_by_dialect.csv)
|
||||
* [data/free_speech_recordings_by_dialect.xlsx](data/free_speech_recordings_by_dialect.xlsx)
|
||||
|
||||
### Segment Friesland (and Groningen) in Gemeentes and Wijken
|
||||
|
||||
[notebook](notebooks/Segment%20Provinces%20in%20Wijken%20and%20Gemeentes.ipynb)
|
||||
|
||||
Some of the wijken are merges, for example part of Leeuwarden, to avoid that the segementation gets too fine
|
||||
grained.
|
||||
|
||||
[notebook](notebooks/Show%20Province%20Segmentations.ipynb)
|
||||
|
||||
Visualized maps of the segmentations.
|
||||
|
||||
Results:
|
||||
|
||||
* data/Friesland_gemeentes.geojson
|
||||
* data/Friesland_gemeentes.kml
|
||||
* data/Friesland_wijken.geojson
|
||||
* data/Friesland_wijken.kml
|
||||
* data/frysian_dialect_regions.geojson
|
||||
* data/Groningen_gemeentes.geojson
|
||||
* data/Groningen_gemeentes.kml
|
||||
* data/Groningen_wijken.geojson
|
||||
* data/Groningen_wijken.kml
|
||||
* data/Zeeland_gemeentes.geojson
|
||||
* data/Zeeland_gemeentes.kml
|
||||
* data/Zeeland_wijken.geojson
|
||||
* data/Zeeland_wijken.kml
|
||||
@@ -0,0 +1 @@
|
||||
{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[6.194671132611735, 53.269759508775365], [6.217094291744268, 53.26526721668054], [6.218947402097325, 53.25987260228332], [6.223971380010156, 53.25724013854463], [6.231665791433949, 53.25694943109232], [6.231513362321069, 53.25504529110772], [6.2345025812283135, 53.25348194874929], [6.233439581575041, 53.25122371062529], [6.229033059133313, 53.25004803348124], [6.231344548545499, 53.246959064534344], [6.230759951840792, 53.24548077526249], [6.224980789525661, 53.24507301726016], [6.217517885857613, 53.242127109259435], [6.22434122928234, 53.238921726347584], [6.215362004493845, 53.23745141488962], [6.213762620013364, 53.2342334650283], [6.217916021271521, 53.231178696954586], [6.224354619940717, 53.2296428479475], [6.224935618887203, 53.22516067461244], [6.2297214798222775, 53.22219612112689], [6.229346640479492, 53.21778057194561], [6.224370611078809, 53.21490401870231], [6.224380432920913, 53.212228113822995], [6.218877326208238, 53.20647655179321], [6.209276398971512, 53.200364969554], [6.199230797209458, 53.198669641533854], [6.198974235395809, 53.19358386848285], [6.192475335152392, 53.18939429817816], [6.180955134010347, 53.170829632069726], [6.17733026726567, 53.168150380053405], [6.176237016929846, 53.159325952382375], [6.1519865208489115, 53.150832787020846], [6.148118320204327, 53.15782744238109], [6.121632917178585, 53.144993408980234], [6.118791567287942, 53.145740548013194], [6.1193385559565865, 53.14941996969155], [6.112537388460171, 53.15019614135907], [6.109025243142256, 53.15219832978642], [6.10501304644401, 53.15179940804972], [6.114593489844947, 53.175977655466184], [6.108946817833281, 53.17633174237709], [6.104618358268969, 53.179340729614054], [6.099772116283385, 53.18576411290965], [6.084052891341338, 53.19576590355943], [6.078558287518519, 53.20671602343492], [6.084109983128598, 53.2084632539372], [6.078723960449081, 53.210677742530635], [6.081904669811584, 53.21117147944512], [6.080137678236041, 53.21315535011946], [6.081699741682283, 53.21408577941732], [6.086289050406518, 53.21502599422193], [6.027244241401107, 53.2301325523495], [6.019789039180608, 53.2409241037087], [6.02309423292633, 53.24279142829998], [6.02780050937838, 53.24139798693858], [6.028816252221567, 53.24275858127642], [6.038848944540122, 53.24261662471477], [6.0745150905708725, 53.24844823013756], [6.110774150557711, 53.25985468575321], [6.1410584115372036, 53.26438293947859], [6.14497815656129, 53.26016481110064], [6.1587806290806535, 53.263683718022804], [6.160523275433989, 53.26198468324357], [6.164195827017465, 53.263957667597616], [6.179490976583689, 53.259054312699796], [6.181184102392232, 53.25965456777388], [6.180721066947198, 53.26104965422539], [6.190384471184848, 53.26337767594658], [6.185599939759812, 53.26781551306844], [6.189220006927044, 53.26989024387363], [6.190720133349364, 53.26858370278516], [6.194671132611735, 53.269759508775365]]]}, "properties": {"GM_CODE": "GM0059", "GM_NAAM": "Achtkarspelen", "WATER": "NEE", "OAD": 426, "STED": 5, "AANT_INW": 27935, "AANT_MAN": 14203, "AANT_VROUW": 13732, "P_00_14_JR": 18, "P_15_24_JR": 12, "P_25_44_JR": 23, "P_45_64_JR": 28, "P_65_EO_JR": 19, "P_ONGEHUWD": 45, "P_GEHUWD": 43, "P_GESCHEID": 6, "P_VERWEDUW": 6, "AANTAL_HH": 11655, "P_EENP_HH": 30, "P_HH_Z_K": 32, "P_HH_M_K": 39, "GEM_HH_GR": 2.4, "P_WEST_AL": 2, "P_N_W_AL": 2, "P_MAROKKO": 0, "P_ANT_ARU": 0, "P_SURINAM": 0, "P_TURKIJE": 0, "P_OVER_NW": 2, "gemeente_naam": "Achtkarspelen"}}, {"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[5.874575981389083, 53.085088543925515], [5.870312657129354, 53.081432132094506], [5.871502123572244, 53.07421001750257], [5.894974095143421, 53.07622850948059], [5.89541785422051, 53.078837357834516], [5.897039315045875, 53.07900549332698], [5.933390280860911, 53.07811136427716], [5.932916708432069, 53.076044325310185], [5.93595182320446, 53.07381540300207], [5.9323046592808995, 53.0732290362582], [5.9308702014396655, 53.070413464097264], [5.937889351180553, 53.0649982179832], [5.941090453986887, 53.06390012670284], [5.944268394888954, 53.065254579809675], [5.947328304436699, 53.06248023076828], [5.942635102237427, 53.05348622265528], [5.957613319344541, 53.05361759377551], [5.9536138313135245, 53.052070855282594], [5.952837460416152, 53.050044659844005], [5.944545542601146, 53.04911179629543], [5.943949487951921, 53.044394211227576], [5.9379993681347045, 53.04426420777933], [5.940199411370168, 53.04218023569443], [5.953087651758684, 53.03834919423904], [5.952178699350277, 53.03720778003764], [5.977036731079396, 53.03012839607421], [5.984062067528566, 53.02636784519819], [5.977122805920699, 53.01016538514069], [5.9719420555020095, 53.00967270891442], [5.973963382348792, 53.00342478216364], [5.97966956858669, 52.99785223232036], [5.97464886109085, 52.99428524648868], [5.976750129809227, 52.99265874584673], [5.962653461430934, 52.98100728403474],Line truncated
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1 @@
|
||||
{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[5.972183712989528, 53.321051729937366], [5.972649444783667, 53.323459310428774], [5.974617105274519, 53.323094554084825], [5.971118458390795, 53.33136874824667], [5.97290140328097, 53.33401217805459], [5.988828240510078, 53.334660797307016], [5.989652143492552, 53.336091865288545], [5.995516626587405, 53.334762585430234], [6.013581255198963, 53.33771098792123], [6.0149777911367135, 53.3364805992652], [6.017554860205618, 53.3370953306608], [6.019363005912589, 53.33500161337293], [6.024782600098534, 53.334670731246625], [6.024756446156252, 53.33273032114674], [6.0264988934152575, 53.33222189939133], [6.023034030754214, 53.32918544950603], [6.022876144148361, 53.32602381771382], [6.024719847213362, 53.32464644597469], [6.022437903780341, 53.32403096499117], [6.022954478786472, 53.32210829964382], [6.02124132025574, 53.320333445464456], [6.020151965590102, 53.30822359787938], [5.998101020604852, 53.310500200623295], [5.975852806584123, 53.30692731635925], [5.970668783608777, 53.31367328171959], [5.974299904424821, 53.31599867168855], [5.972183712989528, 53.321051729937366]]]}, "properties": {"WK_CODE": "WK005800", "WK_NAAM": "Dokkum", "GM_CODE": "GM0058", "GM_NAAM": "Dongeradeel", "IND_WBI": 1, "WATER": "NEE", "OAD": 935, "STED": 4, "AANT_INW": 12540, "AANT_MAN": 6080, "AANT_VROUW": 6460, "P_00_14_JR": 17, "P_15_24_JR": 12, "P_25_44_JR": 21, "P_45_64_JR": 28, "P_65_EO_JR": 23, "P_ONGEHUWD": 45, "P_GEHUWD": 42, "P_GESCHEID": 7, "P_VERWEDUW": 6, "AANTAL_HH": 5570, "P_EENP_HH": 36, "P_HH_Z_K": 31, "P_HH_M_K": 33, "GEM_HH_GR": 2.2, "P_WEST_AL": 3, "P_N_W_AL": 3, "P_MAROKKO": 0, "P_ANT_ARU": 0, "P_SURINAM": 0, "P_TURKIJE": 0, "P_OVER_NW": 3, "gemeente_en_wijk_naam": "Dongeradeel, Dokkum"}}, {"type": "Feature", "geometry": {"type": "MultiPolygon", "coordinates": [[[[6.072746965016547, 53.32486866710904], [6.072700601033454, 53.32486839406934], [6.072746973253208, 53.324869184781484], [6.072746965016547, 53.32486866710904]]], [[[6.0759561816643055, 53.37312922936816], [6.072748066974295, 53.370230197788324], [6.0752655578495105, 53.365798867584445], [6.086521267398218, 53.363239356148796], [6.082574229622848, 53.35279822233953], [6.094621430113428, 53.35331599065063], [6.080085673744459, 53.34335757054949], [6.080814749998407, 53.34237156240564], [6.066679950861687, 53.33685890057919], [6.065234168475948, 53.33835014728265], [6.062546118172569, 53.33762674592004], [6.063205060855979, 53.33530061625888], [6.066655308724881, 53.33344964672852], [6.065649785281447, 53.33160952275595], [6.06733858694417, 53.330997323658046], [6.065897005115674, 53.33004223482746], [6.067404400613272, 53.327763855588465], [6.066227593986631, 53.32751948129203], [6.071219889834814, 53.32470721385325], [6.069334551855985, 53.32394766744419], [6.0359064799445905, 53.32426392429957], [6.032962565750841, 53.325630418778424], [6.024526019023805, 53.32461183967918], [6.022876144148361, 53.32602381771382], [6.023034030754215, 53.32918544950603], [6.0264988934152575, 53.33222189939133], [6.024756446156252, 53.33273032114674], [6.024782600098534, 53.334670731246625], [6.019363005912589, 53.33500161337293], [6.0175548602056175, 53.3370953306608], [6.0149777911367135, 53.3364805992652], [6.014092972417096, 53.33765969176471], [5.995516626587407, 53.334762585430234], [5.993100803235959, 53.3362054938723], [5.989652143492552, 53.336091865288545], [5.988828240510079, 53.334660797307016], [5.983346652432416, 53.334386941702924], [5.9826127228853165, 53.335666054489536], [5.9827015425548975, 53.338134793740096], [5.987148944460353, 53.33873389677872], [5.991707200958003, 53.34276042605685], [5.989047044644044, 53.344565419758645], [5.990361842824458, 53.34854225470637], [6.005235720243911, 53.351129755866594], [6.0080966064774906, 53.350680638246835], [6.008755130917137, 53.34797320480291], [6.011797802445011, 53.34664176084195], [6.020405957928087, 53.348657430602195], [6.023471458821315, 53.352392212983766], [6.019789912722901, 53.36457840158127], [6.025670207009469, 53.36642273958497], [6.025073889562496, 53.36722733214403], [6.042867027887497, 53.37041815622733], [6.042537185755538, 53.37148889409982], [6.045416701678048, 53.37286274504709], [6.05002321350063, 53.371242177188385], [6.054922296669481, 53.371918078096115], [6.059499613288087, 53.36893407670462], [6.062417104803106, 53.37132443327753], [6.067905957609064, 53.371022205621536], [6.068708428041461, 53.37488758881526], [6.073009736877168, 53.37885553818263], [6.078403346168741, 53.37485780362777], [6.0759561816643055, 53.37312922936816]]]]}, "properties": {"WK_CODE": "WK005801", "WK_NAAM": "Metslawier", "GM_CODE": "GM0058", "GM_NAAM": "Dongeradeel", "IND_WBI": 1, "WATER": "NEE", "OAD": 106, "STED": 5, "AANT_INW": 1675, "AANT_MAN": 845, "AANT_VROUW": 830, "P_00_14_JR": 17, "P_15_24_JR": 13, "P_25_44_JR": 19, "P_45_64_JR": 29, "P_65_EO_JR": 23, "P_ONGEHUWD": 43, "P_GEHUWD": 45, "P_GLine truncated
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1 @@
|
||||
{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[6.8855601359692695, 53.34256345354651], [6.882550668581281, 53.33804135418307], [6.883528203144425, 53.3365591803888], [6.881731093766441, 53.328542008621575], [6.881971280237562, 53.32482494817867], [6.883446737002327, 53.3237436560081], [6.883006187796015, 53.31641047874289], [6.885622702916093, 53.309134415555356], [6.88816084481783, 53.30965500478254], [6.887377119926675, 53.29788201628206], [6.860723255060785, 53.29498698831594], [6.860254505250926, 53.296325742579526], [6.8511578796984285, 53.29703818134049], [6.845805646588011, 53.290126005402925], [6.8280725142154255, 53.29109183745557], [6.825161691175255, 53.297622304874174], [6.816649353256025, 53.29518208918807], [6.8073693725380355, 53.30479174525275], [6.811603755504811, 53.30621873913264], [6.803338104106272, 53.31592011843836], [6.806084716809961, 53.31708166711125], [6.804295062724623, 53.32041995705953], [6.8066037491985005, 53.32145868992455], [6.804483037255389, 53.32392668358702], [6.806825974358447, 53.324008309842085], [6.807360819958221, 53.32595016580626], [6.810476670209621, 53.32649311834685], [6.81063228142369, 53.325206032801745], [6.813459251069192, 53.324727737211916], [6.815322776380392, 53.32676219969009], [6.823694045993746, 53.3281357923561], [6.83445695331196, 53.32711512302076], [6.838148446410324, 53.329425488672754], [6.838919983642179, 53.33057262766401], [6.8337255002010435, 53.33686081518745], [6.834532808465355, 53.34005616532168], [6.833158934855956, 53.3418476371421], [6.836150842582004, 53.34513091656879], [6.8417384725795864, 53.3455414792522], [6.844526909496268, 53.34350806639188], [6.849096841001931, 53.3448057099293], [6.861213716958163, 53.34406864409997], [6.866797517878062, 53.34180561085421], [6.86716873199598, 53.34339461095312], [6.8738025617035206, 53.342948873345705], [6.875429323102745, 53.347350438078784], [6.885405185604165, 53.34512803954309], [6.8855601359692695, 53.34256345354651]]]}, "properties": {"GM_CODE": "GM0003", "GM_NAAM": "Appingedam", "WATER": "NEE", "OAD": 1051, "STED": 3, "AANT_INW": 11801, "AANT_MAN": 5751, "AANT_VROUW": 6050, "P_00_14_JR": 15, "P_15_24_JR": 10, "P_25_44_JR": 21, "P_45_64_JR": 30, "P_65_EO_JR": 24, "P_ONGEHUWD": 42, "P_GEHUWD": 42, "P_GESCHEID": 9, "P_VERWEDUW": 7, "AANTAL_HH": 5540, "P_EENP_HH": 37, "P_HH_Z_K": 32, "P_HH_M_K": 31, "GEM_HH_GR": 2.1, "P_WEST_AL": 7, "P_N_W_AL": 7, "P_MAROKKO": 0, "P_ANT_ARU": 1, "P_SURINAM": 1, "P_TURKIJE": 2, "P_OVER_NW": 3, "gemeente_naam": "Appingedam"}}, {"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[6.579810525341259, 53.345205280823016], [6.588220581445681, 53.34223392640596], [6.595831080481451, 53.34714129526492], [6.601448649043975, 53.34042356778854], [6.6046945162484, 53.340804596033614], [6.6053658397639206, 53.337515710064125], [6.592621854377384, 53.335715829578106], [6.5978872470782575, 53.33566095131361], [6.601710654692833, 53.32939887701157], [6.610193618621906, 53.33011464249402], [6.6143355036046945, 53.325202984756544], [6.613005903344689, 53.323217384758905], [6.619862411756754, 53.31442816801208], [6.637675016032265, 53.31463820255846], [6.6429507966542705, 53.30789492616749], [6.654053507981462, 53.30864458271127], [6.625848035817091, 53.266197148524974], [6.633451942684508, 53.25976035798305], [6.63602050505577, 53.25139637148865], [6.61929703445614, 53.24944790484503], [6.6183458724334745, 53.25148594117891], [6.606407305514315, 53.251416600219606], [6.606351363168322, 53.25374085845519], [6.586327747281687, 53.25584608977493], [6.588693401656872, 53.26255087053185], [6.567230182175058, 53.26149408826001], [6.5666012606018445, 53.263607365888554], [6.552573307169593, 53.26216831980907], [6.5495519539831575, 53.264409026517306], [6.55575979609764, 53.27597314554233], [6.560498424483237, 53.31408519020955], [6.568242539937957, 53.335161107246904], [6.567056595771248, 53.34107655693942], [6.568839197030759, 53.34538773964942], [6.573725215236905, 53.3452277590027], [6.576202799801561, 53.34742498858754], [6.579810525341259, 53.345205280823016]]]}, "properties": {"GM_CODE": "GM0005", "GM_NAAM": "Bedum", "WATER": "NEE", "OAD": 685, "STED": 4, "AANT_INW": 10475, "AANT_MAN": 5235, "AANT_VROUW": 5240, "P_00_14_JR": 16, "P_15_24_JR": 11, "P_25_44_JR": 21, "P_45_64_JR": 30, "P_65_EO_JR": 21, "P_ONGEHUWD": 44, "P_GEHUWD": 45, "P_GESCHEID": 6, "P_VERWEDUW": 5, "AANTAL_HH": 4391, "P_EENP_HH": 29, "P_HH_Z_K": 35, "P_HH_M_K": 36, "GEM_HH_GR": 2.3, "P_WEST_AL": 4, "P_N_W_AL": 3, "P_MAROKKO": 0, "P_ANT_ARU": 0, "P_SURINAM": 0, "P_TURKIJE": 0, "P_OVER_NW": 3, "gemeente_naam": "Bedum"}}, {"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[6.740985642946804, 53.31196573545535], [6.74794841031909, 53.31178105816719], [6.749350894861443, 53.30984306842727], [6.7449104456782845, 53.30701964885098], [6.75308153841477, 53.29884707948509], [6.755538667126776, 53.29963374201046], Line truncated
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1 @@
|
||||
{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[6.831991760473089, 53.3272881345734], [6.83445695331196, 53.32711512302076], [6.83892530950616, 53.33053287007227], [6.833731746874434, 53.33681300381805], [6.834532808465354, 53.34005616532168], [6.833158934855956, 53.3418476371421], [6.836150842582004, 53.34513091656879], [6.8417384725795864, 53.3455414792522], [6.844526909496268, 53.34350806639188], [6.8490968410019315, 53.3448057099293], [6.861213716958163, 53.34406864409997], [6.866797517878064, 53.34180561085421], [6.8671687319959815, 53.34339461095312], [6.873802561703521, 53.342948873345705], [6.875429323102745, 53.347350438078784], [6.885405185604165, 53.34512803954309], [6.885504665237992, 53.34139727799965], [6.882550668581281, 53.33804135418307], [6.883528203144426, 53.3365591803888], [6.881731093766443, 53.328542008621575], [6.881971280237561, 53.32482494817867], [6.883446737002325, 53.3237436560081], [6.883006187796017, 53.316410478742895], [6.885622702916093, 53.309134415555356], [6.88816084481783, 53.30965500478254], [6.887377119926675, 53.29788201628206], [6.860723255060785, 53.29498698831594], [6.860254505250926, 53.296325742579526], [6.8511578796984285, 53.29703818134049], [6.845805646588011, 53.290126005402925], [6.8280725142154255, 53.29109183745557], [6.825161691175254, 53.297622304874174], [6.816649353256025, 53.29518208918807], [6.807369372538035, 53.30479174525275], [6.811603755504811, 53.30621873913264], [6.803338104106272, 53.31592011843836], [6.806084716809961, 53.31708166711125], [6.804295062724623, 53.32041995705953], [6.806603749198499, 53.32145868992455], [6.804483037255388, 53.32392668358702], [6.806825974358446, 53.324008309842085], [6.80736081995822, 53.32595016580626], [6.810476670209621, 53.32649311834685], [6.810632281423689, 53.325206032801745], [6.813459251069193, 53.324727737211916], [6.815322776380392, 53.32676219969009], [6.823694045993745, 53.3281357923561], [6.831991760473089, 53.3272881345734]]]}, "properties": {"WK_CODE": "WK000300", "WK_NAAM": "Wijk 00", "GM_CODE": "GM0003", "GM_NAAM": "Appingedam", "IND_WBI": 1, "WATER": "NEE", "OAD": 1051, "STED": 3, "AANT_INW": 11800, "AANT_MAN": 5750, "AANT_VROUW": 6050, "P_00_14_JR": 15, "P_15_24_JR": 10, "P_25_44_JR": 21, "P_45_64_JR": 30, "P_65_EO_JR": 24, "P_ONGEHUWD": 42, "P_GEHUWD": 42, "P_GESCHEID": 9, "P_VERWEDUW": 7, "AANTAL_HH": 5540, "P_EENP_HH": 37, "P_HH_Z_K": 32, "P_HH_M_K": 31, "GEM_HH_GR": 2.1, "P_WEST_AL": 7, "P_N_W_AL": 7, "P_MAROKKO": 0, "P_ANT_ARU": 1, "P_SURINAM": 1, "P_TURKIJE": 2, "P_OVER_NW": 3, "gemeente_en_wijk_naam": "Appingedam, Wijk 00"}}, {"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[6.5575574187022, 53.287717655433184], [6.560498424483237, 53.31408519020955], [6.568242539937957, 53.335161107246904], [6.5670565957712475, 53.34107655693942], [6.568839197030759, 53.34538773964942], [6.573725215236905, 53.3452277590027], [6.574575417141244, 53.347205311666514], [6.588160804716681, 53.342231180588094], [6.595831080481451, 53.34714129526492], [6.601448649043975, 53.34042356778854], [6.604694516248399, 53.340804596033614], [6.6053658397639206, 53.337515710064125], [6.592621854377384, 53.335715829578106], [6.5978872470782575, 53.33566095131361], [6.601710654692831, 53.32939887701157], [6.610193618621906, 53.33011464249402], [6.614335503604693, 53.325202984756544], [6.613005903344689, 53.323217384758905], [6.619862411756755, 53.31442816801208], [6.637675016032265, 53.31463820255846], [6.642950796654272, 53.30789492616749], [6.654053507981462, 53.30864458271127], [6.625848035817091, 53.266197148524974], [6.633451942684508, 53.25976035798305], [6.635565993294051, 53.25123626088163], [6.61929703445614, 53.24944790484503], [6.6183458724334745, 53.25148594117891], [6.606407305514315, 53.251416600219606], [6.606351363168321, 53.25374085845519], [6.586327747281687, 53.25584608977493], [6.588693401656872, 53.26255087053185], [6.567230182175058, 53.26149408826001], [6.566601260601844, 53.263607365888554], [6.551387239099513, 53.26237505082999], [6.549551953983157, 53.264409026517306], [6.555534330356754, 53.27500907021281], [6.5575574187022, 53.287717655433184]]]}, "properties": {"WK_CODE": "WK000500", "WK_NAAM": "Wijk 00", "GM_CODE": "GM0005", "GM_NAAM": "Bedum", "IND_WBI": 1, "WATER": "NEE", "OAD": 685, "STED": 4, "AANT_INW": 10475, "AANT_MAN": 5235, "AANT_VROUW": 5240, "P_00_14_JR": 16, "P_15_24_JR": 11, "P_25_44_JR": 21, "P_45_64_JR": 30, "P_65_EO_JR": 21, "P_ONGEHUWD": 44, "P_GEHUWD": 45, "P_GESCHEID": 6, "P_VERWEDUW": 5, "AANTAL_HH": 4390, "P_EENP_HH": 29, "P_HH_Z_K": 35, "P_HH_M_K": 36, "GEM_HH_GR": 2.3, "P_WEST_AL": 4, "P_N_W_AL": 3, "P_MAROKKO": 0, "P_ANT_ARU": 0, "P_SURINAM": 0, "P_TURKIJE": 0, "P_OVER_NW": 3, "gemeente_en_wijk_naam": "Bedum, Wijk 00"}}, {"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[6.664142885546274, 53.2436207887198], [6.643621733580779, 53.23505563459839], [6.635043509863Line truncated
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1 @@
|
||||
{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "MultiPolygon", "coordinates": [[[[3.6987305164410342, 51.4697043301031], [3.6956781493345345, 51.47111470835397], [3.7022432247064776, 51.47453695006143], [3.7056671069413287, 51.47085176073079], [3.6987305164410342, 51.4697043301031]]], [[[3.718513886312421, 51.502015615124634], [3.774423498484817, 51.497345130201346], [3.7829739166839498, 51.49461147176804], [3.8003300946825895, 51.485608612290086], [3.8104630496968444, 51.483125306444414], [3.841228213945917, 51.485298597586265], [3.8696566399884764, 51.4825703253627], [3.8744229297237975, 51.4800134361481], [3.881611954975277, 51.48104188284481], [3.912877736897704, 51.479121571879865], [3.9134147682439617, 51.4776203932737], [3.907741825905159, 51.46948895221429], [3.9162730682635303, 51.463402119889615], [3.9285103005457165, 51.4587906438447], [3.925433178001758, 51.451527515097], [3.922644934263146, 51.45020847930725], [3.9253870868294034, 51.44552900617072], [3.920983557918589, 51.444153316251395], [3.9258294448723694, 51.437795710661604], [3.9255968256438067, 51.43475109267484], [3.919025553076898, 51.42741301649625], [3.919150902653222, 51.42562065201858], [3.9166711516202604, 51.425793865498456], [3.919178651640572, 51.425311722453905], [3.916992498569708, 51.42132089151521], [3.9141471354269846, 51.419665486394564], [3.9143467793337567, 51.417522529393345], [3.911432190630488, 51.41572119008867], [3.9117235617022863, 51.41403655380365], [3.8997828903107736, 51.39504060173984], [3.893782559780264, 51.39352081646814], [3.87365552193715, 51.397935372317875], [3.8643738777888843, 51.395482128321774], [3.8588130252112913, 51.391808002320644], [3.8511779838974918, 51.39196129371854], [3.848618395474118, 51.39040104650771], [3.8124969722492836, 51.38586504037446], [3.7898393958665135, 51.399834336138795], [3.775619075702943, 51.40573939307307], [3.778067644105972, 51.409229105874516], [3.7762206967977363, 51.410625052818176], [3.7648581467718234, 51.410645211274456], [3.7537987893422686, 51.415282852048016], [3.74431070916184, 51.411881281399275], [3.735573444049288, 51.41177368260322], [3.725746112059919, 51.41561594575053], [3.72098289989563, 51.4264209845098], [3.7175145200748987, 51.42743005145111], [3.696391895227276, 51.44585113037731], [3.7037003638041535, 51.45026382022898], [3.706218739069919, 51.44807611313543], [3.7010089294629003, 51.4432497583315], [3.7033976436870124, 51.44127380707507], [3.7105085108553264, 51.446052026237034], [3.718657761622026, 51.44197618148555], [3.722847647169205, 51.445086773661174], [3.7133000518529267, 51.4505958629702], [3.7276638652373895, 51.456184226665826], [3.7253782697009883, 51.45875597509628], [3.7117147976878453, 51.454233660877556], [3.710429742470537, 51.45509993094616], [3.714754711725076, 51.46312745653858], [3.717506193375473, 51.46426463799744], [3.7160757490157907, 51.466348310261026], [3.721866654583978, 51.473436248784886], [3.719103611568256, 51.475559904533554], [3.714376113641095, 51.47133947509661], [3.712423892297092, 51.47143852438761], [3.7060461291037083, 51.47727546072572], [3.7044903855501383, 51.48166848585153], [3.7000912399282275, 51.48319452601389], [3.6990505300424803, 51.492340964447855], [3.7055363846272575, 51.50245590102015], [3.718513886312421, 51.502015615124634]]], [[[3.7171827949622456, 51.42730235234943], [3.717274504109915, 51.42733765620592], [3.717210240808265, 51.42728660697395], [3.7171827949622456, 51.42730235234943]]]]}, "properties": {"GM_CODE": "GM0654", "GM_NAAM": "Borsele", "WATER": "NEE", "OAD": 319, "STED": 5, "AANT_INW": 22716, "AANT_MAN": 11526, "AANT_VROUW": 11190, "P_00_14_JR": 17, "P_15_24_JR": 12, "P_25_44_JR": 22, "P_45_64_JR": 30, "P_65_EO_JR": 20, "P_ONGEHUWD": 42, "P_GEHUWD": 46, "P_GESCHEID": 7, "P_VERWEDUW": 5, "AANTAL_HH": 9484, "P_EENP_HH": 30, "P_HH_Z_K": 34, "P_HH_M_K": 36, "GEM_HH_GR": 2.4, "P_WEST_AL": 6, "P_N_W_AL": 3, "P_MAROKKO": 0, "P_ANT_ARU": 0, "P_SURINAM": 0, "P_TURKIJE": 0, "P_OVER_NW": 2, "gemeente_naam": "Borsele"}}, {"type": "Feature", "geometry": {"type": "MultiPolygon", "coordinates": [[[[3.7200976046716447, 51.52799905719433], [3.7196645928707595, 51.52791174668519], [3.7199944970536865, 51.52866112154788], [3.7202066512761043, 51.528574081330504], [3.7200976046716447, 51.52799905719433]]], [[[3.720453679646041, 51.5319162200574], [3.7209420637648076, 51.5308084063778], [3.720865029608876, 51.52921277119746], [3.7176835909987274, 51.52871669502689], [3.720453679646041, 51.5319162200574]]], [[[3.724111782661497, 51.53454186416382], [3.723545728631711, 51.532872697763366], [3.7220798532747486, 51.53329299341324], [3.7215110098334763, 51.53077413930211], [3.7215169445694025, 51.53346184383261], [3.724111782661497, 51.53454186416382]]], [[[3.7855876420919046, 51.545718462809816], [3.7887625621946905, 51.54443219705559], [3.788770416548278, 51.54442901388238], [3.786525506048482, 51.54456106368389], [3.7855876420919046, 51.545718462809816]]], [[Line truncated
|
||||
Whitespace-only changes.
@@ -0,0 +1 @@
|
||||
{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[3.855881807765256, 51.41690567371998], [3.8560811814378417, 51.419693523829295], [3.8684417622994145, 51.422865692619645], [3.872402641442673, 51.421997696852436], [3.881063671373239, 51.42535610679279], [3.8808026018158346, 51.42651975132301], [3.885281747736284, 51.426906496432345], [3.8850032927023848, 51.4184469714124], [3.89131043902634, 51.41714611764201], [3.8997424581396003, 51.41828248376253], [3.9118349694469434, 51.41605806080793], [3.9007169262697823, 51.39574192965722], [3.893963530281273, 51.39350967171334], [3.8762095981487366, 51.39744135905317], [3.876689809413183, 51.39989823874761], [3.873227366633293, 51.40218989301174], [3.8581143645163554, 51.40335268453301], [3.8592360481981176, 51.4043664102167], [3.8575330157153473, 51.40466406917531], [3.860648872550636, 51.409479467564175], [3.8628159756476346, 51.40945303671827], [3.863883312923662, 51.41176843709817], [3.8633894082367903, 51.413896275595945], [3.8586599056683704, 51.413339921978945], [3.859413268990898, 51.414724148987844], [3.855881807765256, 51.41690567371998]]]}, "properties": {"WK_CODE": "WK065401", "WK_NAAM": "Baarland", "GM_CODE": "GM0654", "GM_NAAM": "Borsele", "IND_WBI": 1, "WATER": "NEE", "OAD": 58, "STED": 5, "AANT_INW": 610, "AANT_MAN": 310, "AANT_VROUW": 300, "P_00_14_JR": 16, "P_15_24_JR": 12, "P_25_44_JR": 18, "P_45_64_JR": 32, "P_65_EO_JR": 22, "P_ONGEHUWD": 44, "P_GEHUWD": 47, "P_GESCHEID": 6, "P_VERWEDUW": 3, "AANTAL_HH": 250, "P_EENP_HH": 26, "P_HH_Z_K": 43, "P_HH_M_K": 31, "GEM_HH_GR": 2.4, "P_WEST_AL": 9, "P_N_W_AL": 0, "P_MAROKKO": -99999999, "P_ANT_ARU": -99999999, "P_SURINAM": -99999999, "P_TURKIJE": -99999999, "P_OVER_NW": -99999999, "gemeente_en_wijk_naam": "Borsele, Baarland"}}, {"type": "Feature", "geometry": {"type": "MultiPolygon", "coordinates": [[[[3.74692747036265, 51.45064495752581], [3.7474565376582625, 51.45182028383209], [3.7645009327304, 51.44285345808824], [3.7608460662545333, 51.436459961540564], [3.7629445045515326, 51.43262003643917], [3.761976912036566, 51.43039131199108], [3.7646120689197797, 51.428793468750385], [3.768468361484768, 51.42947018810848], [3.772422920140399, 51.42782220444677], [3.7790982711895844, 51.430666279650836], [3.780922651093859, 51.42758081490607], [3.7945051261505194, 51.4283522918307], [3.788448314094966, 51.421373117737424], [3.7791070937749125, 51.416154544915656], [3.7812245260934487, 51.41478490805532], [3.7778770283801495, 51.40967311750412], [3.7648581467718234, 51.410645211274456], [3.753852769764586, 51.415277795901694], [3.74431070916184, 51.411881281399275], [3.735573444049288, 51.41177368260322], [3.725746112059919, 51.41561594575053], [3.7210146142109153, 51.42638087601718], [3.7175145200748987, 51.42743005145111], [3.742954437590356, 51.43384300207708], [3.7414370295955695, 51.43756969749537], [3.7492009917716858, 51.44540862110262], [3.74692747036265, 51.45064495752581]]], [[[3.7171827949622456, 51.42730235234943], [3.717274504109915, 51.42733765620592], [3.717210240808265, 51.42728660697395], [3.7171827949622456, 51.42730235234943]]]]}, "properties": {"WK_CODE": "WK065402", "WK_NAAM": "Borssele", "GM_CODE": "GM0654", "GM_NAAM": "Borsele", "IND_WBI": 1, "WATER": "NEE", "OAD": 162, "STED": 5, "AANT_INW": 1420, "AANT_MAN": 730, "AANT_VROUW": 690, "P_00_14_JR": 24, "P_15_24_JR": 14, "P_25_44_JR": 25, "P_45_64_JR": 25, "P_65_EO_JR": 13, "P_ONGEHUWD": 49, "P_GEHUWD": 42, "P_GESCHEID": 6, "P_VERWEDUW": 4, "AANTAL_HH": 515, "P_EENP_HH": 30, "P_HH_Z_K": 29, "P_HH_M_K": 41, "GEM_HH_GR": 2.7, "P_WEST_AL": 7, "P_N_W_AL": 2, "P_MAROKKO": 0, "P_ANT_ARU": 0, "P_SURINAM": 0, "P_TURKIJE": 0, "P_OVER_NW": 2, "gemeente_en_wijk_naam": "Borsele, Borssele"}}, {"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[3.8123818247892243, 51.42968116261287], [3.8163180093791373, 51.426645296103146], [3.8125606295330283, 51.4240684004055], [3.820444879952193, 51.41872910361769], [3.823404764681509, 51.41084517107377], [3.819521424609661, 51.41007184749489], [3.8186925908232254, 51.412105954224785], [3.8139651868797557, 51.41087551611917], [3.8135416259598016, 51.41220933039848], [3.799235022561335, 51.4122904140107], [3.7947416939362593, 51.40938177841996], [3.8047101365822424, 51.40334491779369], [3.7971452449502086, 51.39856710160859], [3.791924857602578, 51.4016459942426], [3.7896495948392035, 51.39992032253597], [3.775582676530318, 51.40578476782475], [3.7812245260934487, 51.41478490805532], [3.7791070937749125, 51.416154544915656], [3.788448314094966, 51.421373117737424], [3.7945051261505194, 51.4283522918307], [3.8123818247892243, 51.42968116261287]]]}, "properties": {"WK_CODE": "WK065403", "WK_NAAM": "Driewegen", "GM_CODE": "GM0654", "GM_NAAM": "Borsele", "IND_WBI": 1, "WATER": "NEE", "OAD": 76, "STED": 5, "AANT_INW": 545, "AANT_MAN": 280, "AANT_VROUW": 265, "P_00_14_JR": 14, "P_15_24_JR": 9, "P_25_44_JR": 19, "P_45_64_JR": 39, "P_65_EO_JR":Line truncated
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,139 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Segment provinces\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"Create wijk and gemeente level segmentations for all Dutch provinces and save as geojson and Gabmap KML.\n",
|
||||
"\n",
|
||||
"All is based on CBS data.\n",
|
||||
"\n",
|
||||
"For Friesland, several wijken are merged.\n",
|
||||
"\n",
|
||||
"Note: only applied to Groningen and Friesland, because other provinces give gemetry errors."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%load_ext autoreload\n",
|
||||
"\n",
|
||||
"%autoreload 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import sys\n",
|
||||
"sys.path.append('../')\n",
|
||||
"\n",
|
||||
"from stimmen.latitude_longitude import reverse_latitude_longitude\n",
|
||||
"from stimmen.shapefile import shapefiles_to_geojson\n",
|
||||
"from stimmen.cbs import gwb_in_province, get_available_provinces\n",
|
||||
"from stimmen.geojson import merge_features\n",
|
||||
"from gabmap import as_gabmap_kml\n",
|
||||
"\n",
|
||||
"from shapely.geometry import shape, box, mapping\n",
|
||||
"\n",
|
||||
"import json\n",
|
||||
"import folium\n",
|
||||
"import pickle\n",
|
||||
"\n",
|
||||
"from collections import defaultdict"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for province in ['Groningen', 'Friesland']:\n",
|
||||
" wijken_geojson = gwb_in_province(province, 'wijk', 2018)\n",
|
||||
" gemeente_geojson = gwb_in_province(province, 'gem', 2018)\n",
|
||||
"\n",
|
||||
" if province == 'Friesland':\n",
|
||||
" for gemeente in {'Ameland', 'Harlingen', 'Schiermonnikoog', 'Terschelling', 'Vlieland'}:\n",
|
||||
" merged_geojson = merge_features(\n",
|
||||
" wijken_geojson.copy(),\n",
|
||||
" condition=lambda feature: feature['properties']['GM_NAAM'] == gemeente,\n",
|
||||
" aggregate={'WK_NAAM': ' '.join}\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" merge_leeuwarden_only_above_latitude = 53.167\n",
|
||||
" wijken_geojson = merge_features(\n",
|
||||
" wijken_geojson,\n",
|
||||
" condition=lambda feature: (\n",
|
||||
" feature['properties']['GM_NAAM'] == 'Leeuwarden' and\n",
|
||||
" shape(feature['geometry']).centroid.y > merge_leeuwarden_only_above_latitude\n",
|
||||
" ),\n",
|
||||
" aggregate={'WK_NAAM': ' '.join}\n",
|
||||
" )\n",
|
||||
" \n",
|
||||
" #Some gemeentes appear twice in the cbs data.\n",
|
||||
" for gemeente in [feature['properties']['GM_NAAM'] for feature in gemeente_geojson['features']]:\n",
|
||||
" gemeente_geojson = merge_features(\n",
|
||||
" gemeente_geojson, condition=lambda feature: feature['properties']['GM_NAAM'] == gemeente)\n",
|
||||
" \n",
|
||||
" for feature in wijken_geojson['features']:\n",
|
||||
" feature['properties']['gemeente_en_wijk_naam'] = (\n",
|
||||
" feature['properties']['GM_NAAM'] +\n",
|
||||
" ', ' +\n",
|
||||
" feature['properties'].get('WK_NAAM', '')\n",
|
||||
" ).replace('&', 'en').replace('/', ' ').replace('\"', ' ').replace(\"'\", ' ')\n",
|
||||
" \n",
|
||||
" for feature in gemeente_geojson['features']:\n",
|
||||
" feature['properties']['gemeente_naam'] = (\n",
|
||||
" feature['properties']['GM_NAAM']\n",
|
||||
" ).replace('&', 'en').replace('/', ' ').replace('\"', ' ').replace(\"'\", ' ')\n",
|
||||
" \n",
|
||||
" with open('../data/{}_wijken.geojson'.format(province), 'w') as f:\n",
|
||||
" json.dump(wijken_geojson, f)\n",
|
||||
" with open('../data/{}_gemeentes.geojson'.format(province), 'w') as f:\n",
|
||||
" json.dump(gemeente_geojson, f)\n",
|
||||
" \n",
|
||||
" with open('../data/{}_wijken.kml'.format(province), 'w') as f:\n",
|
||||
" f.write(as_gabmap_kml(wijken_geojson, name_property='gemeente_en_wijk_naam'))\n",
|
||||
" with open('../data/{}_gemeentes.kml'.format(province), 'w') as f:\n",
|
||||
" f.write(as_gabmap_kml(gemeente_geojson, name_property='gemeente_naam'))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.6.5"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%load_ext autoreload\n",
|
||||
"\n",
|
||||
"%autoreload 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import sys\n",
|
||||
"sys.path.append('../')\n",
|
||||
"import json\n",
|
||||
"\n",
|
||||
"from stimmen.latitude_longitude import reverse_latitude_longitude\n",
|
||||
"import folium\n",
|
||||
"\n",
|
||||
"from stimmen.cbs import get_available_provinces, province_geojson\n",
|
||||
"from shapely.geometry import shape\n",
|
||||
"\n",
|
||||
"import folium\n",
|
||||
"from IPython.display import display"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Groningen\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><iframe src=\"data:text/html;charset=utf-8;base64,PCFET0NUWVBFIGh0bWw+CjxoZWFkPiAgICAKICAgIDxtZXRhIGh0dHAtZXF1aXY9ImNvbnRlbnQtdHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PVVURi04IiAvPgogICAgPHNjcmlwdD5MX1BSRUZFUl9DQU5WQVM9ZmFsc2U7IExfTk9fVE9VQ0g9ZmFsc2U7IExfRElTQUJMRV8zRD1mYWxzZTs8L3NjcmlwdD4KICAgIDxzY3JpcHQgc3JjPSJodHRwczovL2Nkbi5qc2RlbGl2ci5uZXQvbnBtL2xlYWZsZXRAMS4yLjAvZGlzdC9sZWFmbGV0LmpzIj48L3NjcmlwdD4KICAgIDxzY3JpcHQgc3JjPSJodHRwczovL2FqYXguZ29vZ2xlYXBpcy5jb20vYWpheC9saWJzL2pxdWVyeS8xLjExLjEvanF1ZXJ5Lm1pbi5qcyI+PC9zY3JpcHQ+CiAgICA8c2NyaXB0IHNyYz0iaHR0cHM6Ly9tYXhjZG4uYm9vdHN0cmFwY2RuLmNvbS9ib290c3RyYXAvMy4yLjAvanMvYm9vdHN0cmFwLm1pbi5qcyI+PC9zY3JpcHQ+CiAgICA8c2NyaXB0IHNyYz0iaHR0cHM6Ly9jZG5qcy5jbG91ZGZsYXJlLmNvbS9hamF4L2xpYnMvTGVhZmxldC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cwOTkyOTMsIDYuODQ5MDk2ODQxMDAxOTMxNV0sIFs1My4zNDQwNjg2NDQwOTk5NywgNi44NjEyMTM3MTY5NTgxNjNdLCBbNTMuMzQxODA1NjEwODU0MjEsIDYuODY2Nzk3NTE3ODc4MDY0XSwgWzUzLjM0MzM5NDYxMDk1MzEyLCA2Ljg2NzE2ODczMTk5NTk4MTVdLCBbNTMuMzQyOTQ4ODczMzQ1NzA1LCA2Ljg3MzgwMjU2MTcwMzUyMV0sIFs1My4zNDczNTA0MzgwNzg3ODQsIDYuODc1NDI5MzIzMTAyNzQ1XSwgWzUzLjM0NTEyODAzOTU0MzA5LCA2Ljg4NTQwNTE4NTYwNDE2NV0sIFs1My4zNDEzOTcyNzc5OTk2NSwgNi44ODU1MDQ2NjUyMzc5OTJdLCBbNTMuMzM4MDQxMzU0MTgzMDcsIDYuODgyNTUwNjY4NTgxMjgxXSwgWzUzLjMzNjU1OTE4MDM4ODgsIDYuODgzNTI4MjAzMTQ0NDI2XSwgWzUzLjMyODU0MjAwODYyMTU3NSwgNi44ODE3MzEwOTM3NjY0NDNdLCBbNTMuMzI0ODI0OTQ4MTc4NjcsIDYuODgxOTcxMjgwMjM3NTYxXSwgWzUzLjMyMzc0MzY1NjAwODEsIDYuODgzNDQ2NzM3MDAyMzI1XSwgWzUzLjMxNjQxMDQ3ODc0Mjg5NSwgNi44ODMwMDYxODc3OTYwMTddLCBbNTMuMzA5MTM0NDE1NTU1MzU2LCA2Ljg4NTYyMjcwMjkxNjA5M10sIFs1My4zMDk2NTUwMDQ3ODI1NCwgNi44ODgxNjA4NDQ4MTc4M10sIFs1My4yOTc4ODIwMTYyODIwNiwgNi44ODczNLine truncated
|
||||
],
|
||||
"text/plain": [
|
||||
"<folium.folium.Map at 0x7f9ea4251cc0>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"ename": "FileNotFoundError",
|
||||
"evalue": "[Errno 2] No such file or directory: '../data/Friesland_gemeentes.geojson'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[0;32m<ipython-input-5-4015368e13b0>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mm\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfolium\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mMap\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcenter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcenter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtiles\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'stamentoner'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mzoom_start\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m9\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'../data/{}_gemeentes.geojson'\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprovince\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'r'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0mgemeentes\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mjson\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'../data/{}_wijken.geojson'\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprovince\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'r'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '../data/Friesland_gemeentes.geojson'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for province in ['Groningen', 'Friesland', 'Zeeland']:\n",
|
||||
" center = shape(province_geojson(province, with_water=True)['geometry']).centroid\n",
|
||||
"\n",
|
||||
" m = folium.Map((center.y, center.x), tiles='stamentoner', zoom_start=9)\n",
|
||||
" \n",
|
||||
" with open('../data/{}_gemeentes.geojson'.format(province), 'r') as f:\n",
|
||||
" gemeentes = json.load(f)\n",
|
||||
" with open('../data/{}_wijken.geojson'.format(province), 'r') as f:\n",
|
||||
" wijken = json.load(f)\n",
|
||||
" \n",
|
||||
" for feature in wijken['features']:\n",
|
||||
" coordinates = reverse_latitude_longitude(feature['geometry']['coordinates'])\n",
|
||||
" polygon = folium.Polygon(coordinates, fill_color=None, color='blue').add_to(m)\n",
|
||||
" \n",
|
||||
" for feature in gemeentes['features']:\n",
|
||||
" coordinates = reverse_latitude_longitude(feature['geometry']['coordinates'])\n",
|
||||
" polygon = folium.Polygon(coordinates, fill_color=None, color='red').add_to(m)\n",
|
||||
" \n",
|
||||
" print(province)\n",
|
||||
" display(m)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.6.5"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
from threading import Thread
|
||||
import time
|
||||
|
||||
from pygeoif.geometry import mapping
|
||||
from shapely.geometry import shape, box
|
||||
|
||||
from stimmen.shapefile import shapefiles_to_geojson
|
||||
|
||||
import os.path
|
||||
|
||||
|
||||
def data_file(*args):
|
||||
return os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
'..',
|
||||
*args
|
||||
)
|
||||
|
||||
__cache = {}
|
||||
__last_access = None
|
||||
|
||||
|
||||
def clear_cache_poll():
|
||||
global __cache, __last_access
|
||||
while True:
|
||||
time.sleep(60*60)
|
||||
if (time.time() - __last_access) > 60*60:
|
||||
__cache = {}
|
||||
|
||||
|
||||
Thread(target=clear_cache_poll, daemon=True).start()
|
||||
|
||||
|
||||
def get_available_provinces():
|
||||
file = data_file('data', 'geo', 'cbs', "2018_Imergis_provinciegrenzen_met_water")
|
||||
provinces = shapefiles_to_geojson(file)['features']
|
||||
return {province['properties']['provincien'] for province in provinces}
|
||||
|
||||
|
||||
def province_geojson(province, with_water=False):
|
||||
global __cache, __last_access
|
||||
file = data_file(
|
||||
'data', 'geo', 'cbs',
|
||||
"2018_Imergis_provinciegrenzen_met_water"
|
||||
if with_water else
|
||||
"2018-Imergis_provinciegrenzen_kustlijn"
|
||||
)
|
||||
|
||||
if (province, with_water) not in __cache:
|
||||
provinces = shapefiles_to_geojson(file)['features']
|
||||
available_provinces = get_available_provinces()
|
||||
|
||||
assert province in available_provinces, "Province {} not found, options: {}".format(
|
||||
province, ', '.join(available_provinces))
|
||||
|
||||
__cache[(province, with_water)] = next(
|
||||
province_ for province_ in provinces if province_['properties']['provincien'] == province)
|
||||
|
||||
__last_access = time.time()
|
||||
return __cache[(province, with_water)]
|
||||
|
||||
|
||||
def gwb_in_province(
|
||||
province='Friesland', region_level='wijk', region_year='2018',
|
||||
polygon_simplification=0.001, province_dilation=0.0005
|
||||
):
|
||||
assert region_level in {'gem', 'wijk', 'buurt'}, (
|
||||
"region_level {} not supported, must be gem, wijk or buurt".format(region_level))
|
||||
assert region_year in {2017, 2018}, (
|
||||
"region_year {} not supported, must 2017 or 2018".format(region_year))
|
||||
|
||||
province_with_water = shape(province_geojson(province, with_water=True)['geometry'])
|
||||
province_bounding_box = box(*province_with_water.bounds)
|
||||
|
||||
province_land_only = shape(province_geojson(province, with_water=False)['geometry'])
|
||||
province_land_only_dilated = province_land_only.buffer(-province_dilation)
|
||||
|
||||
geojson = shapefiles_to_geojson(
|
||||
data_file('data', 'geo', 'cbs', '{}_{}'.format(region_level, region_year)))
|
||||
shapes = [shape(geojson_['geometry']) for geojson_ in geojson['features']]
|
||||
|
||||
shapes, geojson = map(list, zip(*(
|
||||
(intersection.simplify(tolerance=polygon_simplification), geojson_)
|
||||
for shape_, geojson_ in zip(shapes, geojson['features'])
|
||||
if province_bounding_box.contains(shape_)
|
||||
for intersection in [shape_.intersection(province_land_only_dilated)] # alias
|
||||
if intersection.area > 0
|
||||
)))
|
||||
|
||||
for geojson_, shape_ in zip(geojson, shapes):
|
||||
geojson_['geometry'] = mapping(shape_)
|
||||
|
||||
return {"type": "FeatureCollection", "features": geojson}
|
||||
@@ -0,0 +1,43 @@
|
||||
from pygeoif.geometry import mapping
|
||||
from shapely.geometry import shape
|
||||
|
||||
|
||||
def merge_features(geojson, condition, aggregate={}):
|
||||
"""Merge the geometries using shapely's union for all the geojson's features that
|
||||
meet the condition, condition get's passed an item of feature. Then aggregate the properties
|
||||
in the aggregate dict using a function that get as input the list of property values off alle
|
||||
matched features. Operates inplace."""
|
||||
indices = [index for index, feature in enumerate(geojson['features']) if condition(feature)]
|
||||
if len(indices) == 0: # also if there is one index, we
|
||||
return geojson
|
||||
properties = {
|
||||
prop: agg([
|
||||
properties_[prop]
|
||||
for index in indices
|
||||
for properties_ in [geojson['features'][index]['properties']]
|
||||
if prop in properties_
|
||||
])
|
||||
for prop, agg in aggregate.items()
|
||||
}
|
||||
properties.update({
|
||||
key: value
|
||||
for index in indices
|
||||
for key, value in geojson['features'][index]['properties'].items()
|
||||
if key not in aggregate
|
||||
})
|
||||
if len(indices) == 1:
|
||||
geojson['features'][indices[0]]['properties'] = properties
|
||||
return geojson
|
||||
|
||||
union = shape(geojson['features'][indices[0]]['geometry'])
|
||||
for index in indices[1:]:
|
||||
union = union.union(shape(geojson['features'][index]['geometry']))
|
||||
|
||||
for index in indices[::-1]: # reverse, such that the 'todo' indices willnot change.
|
||||
del geojson['features'][index]
|
||||
|
||||
geojson['features'].append({
|
||||
'geometry': mapping(union),
|
||||
'properties': properties
|
||||
})
|
||||
return geojson
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
def reverse_latitude_longitude(rd_multipolygon):
|
||||
if len(rd_multipolygon) == 2 and tuple(map(type, rd_multipolygon)) == (float, float):
|
||||
return rd_multipolygon[::-1]
|
||||
return [
|
||||
reverse_latitude_longitude(element)
|
||||
for element in rd_multipolygon
|
||||
]
|
||||
@@ -0,0 +1,43 @@
|
||||
from osgeo.osr import SpatialReference, CoordinateTransformation
|
||||
import shapefile
|
||||
|
||||
epsg28992 = SpatialReference()
|
||||
epsg28992.ImportFromEPSG(28992)
|
||||
|
||||
epsg28992.SetTOWGS84(565.237 ,50.0087 ,465.658 ,-0.406857 ,0.350733 ,-1.87035 ,4.0812)
|
||||
|
||||
epsg4326 = SpatialReference()
|
||||
epsg4326.ImportFromEPSG(4326)
|
||||
|
||||
rd2latlon = CoordinateTransformation(epsg28992, epsg4326)
|
||||
|
||||
|
||||
def rd_to_longlat(rd_multipolygon):
|
||||
if len(rd_multipolygon) == 2 and tuple(map(type, rd_multipolygon)) == (float, float):
|
||||
return list(rd2latlon.TransformPoint(*rd_multipolygon)[:2])
|
||||
return [
|
||||
rd_to_longlat(element)
|
||||
for element in rd_multipolygon
|
||||
]
|
||||
|
||||
|
||||
def shapefiles_to_geojson(filename):
|
||||
shape_file = shapefile.Reader(filename)
|
||||
fields = shape_file.fields[1:]
|
||||
field_names = [field[0] for field in fields]
|
||||
|
||||
buffer = []
|
||||
for shape_record in shape_file.shapeRecords():
|
||||
properties = dict(zip(field_names, shape_record.record))
|
||||
geometry = shape_record.shape.__geo_interface__
|
||||
geometry['coordinates'] = rd_to_longlat(geometry['coordinates'])
|
||||
|
||||
buffer.append({
|
||||
'type': "Feature",
|
||||
'geometry': geometry,
|
||||
'properties': properties
|
||||
})
|
||||
return {
|
||||
"type": "FeatureCollection",
|
||||
"features": buffer
|
||||
}
|
||||
Reference in new issue
Block a user