Skip to content

Commit

Permalink
Generate AOIs in correct CRS
Browse files Browse the repository at this point in the history
  • Loading branch information
olafveerman committed Oct 16, 2024
1 parent 2213ed9 commit c1a3427
Show file tree
Hide file tree
Showing 7 changed files with 294 additions and 23 deletions.
72 changes: 72 additions & 0 deletions config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
################################################
############### .gitignore ##################
################################################
#
# This file is only relevant if you are using git.
#
# Files which match the splat patterns below will
# be ignored by git. This keeps random crap and
# and sensitive credentials from being uploaded to
# your repository. It allows you to configure your
# app for your machine without accidentally
# committing settings which will smash the local
# settings of other developers on your team.
#
# Some reasonable defaults are included below,
# but, of course, you should modify/extend/prune
# to fit your needs!
################################################

app/scripts/time.json

node_modules
bower_components
.sass-cache
test/bower_components


################################################
# Node.js / NPM
#
# Common files generated by Node, NPM, and the
# related ecosystem.
################################################

lib-cov
*.seed
*.log
*.out
*.pid
npm-debug.log
yarn-error.log
.parcel-cache


################################################
# Apidocs
#
# Common files generated by apidocs and other docs
################################################


################################################
# Miscellaneous
#
# Common files generated by text editors,
# operating systems, file systems, etc.
################################################

*~
*#
.DS_STORE
.DS_Store
.netbeans
nbproject
.idea
.resources
.node_history
temp
tmp
.tmp
dist
parcel-bundle-reports
1 change: 1 addition & 0 deletions config/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
2 changes: 1 addition & 1 deletion config/aoi.geojson
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"type":"FeatureCollection","name":"NUTS_RG_20M_2024_3857.geojson","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::3857"}},"features":[{"type":"Feature","properties":{"NUTS_ID":"BE100","LEVL_CODE":3,"CNTR_CODE":"BE","NAME_LATN":"Arr. de Bruxelles-Capitale/Arr. Brussel-Hoofdstad","NUTS_NAME":"Arr. de Bruxelles-Capitale/Arr. Brussel-Hoofdstad","MOUNT_TYPE":null,"URBN_TYPE":null,"COAST_TYPE":null},"geometry":{"type":"Polygon","coordinates":[[[475079.60350000113,6598788.681599997],[491214.3660000004,6606259.768399999],[501681.9475999996,6583121.435099997],[484071.2923000008,6580378.466600001],[475079.60350000113,6598788.681599997]]]}},{"type":"Feature","properties":{"NUTS_ID":"BE10","LEVL_CODE":2,"CNTR_CODE":"BE","NAME_LATN":"Région de Bruxelles-Capitale/ Brussels Hoofdstedelijk Gewest","NUTS_NAME":"Région de Bruxelles-Capitale/ Brussels Hoofdstedelijk Gewest","MOUNT_TYPE":null,"URBN_TYPE":null,"COAST_TYPE":null},"geometry":{"type":"Polygon","coordinates":[[[475079.60350000113,6598788.681599997],[491214.3660000004,6606259.768399999],[501681.9475999996,6583121.435099997],[484071.2923000008,6580378.466600001],[475079.60350000113,6598788.681599997]]]}},{"type":"Feature","properties":{"NUTS_ID":"BE1","LEVL_CODE":1,"CNTR_CODE":"BE","NAME_LATN":"Région de Bruxelles-Capitale/Brussels Hoofdstedelijk Gewest","NUTS_NAME":"Région de Bruxelles-Capitale/Brussels Hoofdstedelijk Gewest","MOUNT_TYPE":null,"URBN_TYPE":null,"COAST_TYPE":null},"geometry":{"type":"Polygon","coordinates":[[[475079.60350000113,6598788.681599997],[491214.3660000004,6606259.768399999],[501681.9475999996,6583121.435099997],[484071.2923000008,6580378.466600001],[475079.60350000113,6598788.681599997]]]}}]}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"NUTS_ID":"EL3","LEVL_CODE":1,"CNTR_CODE":"EL","NAME_LATN":"Attiki","NUTS_NAME":"Αττική ","MOUNT_TYPE":null,"URBN_TYPE":null,"COAST_TYPE":null},"geometry":{"type":"MultiPolygon","coordinates":[[[[24.04977480513024,38.20839666421797],[23.997896085071012,38.090296275187015],[24.024553777976852,37.99940936719728],[24.07670041877294,37.770291311333665],[24.031592564216492,37.66331226380242],[23.94971710795047,37.661599686223674],[23.883103057282845,37.77290186443375],[23.743593100047764,37.85380946602965],[23.67222833235625,37.94189303833763],[23.514318790417683,37.90456318226443],[23.43232078418396,37.89152335715787],[23.414974182198648,37.96978530235251],[23.2477737641284,37.97234067419783],[23.179699368117465,37.95159003439842],[23.106588181190507,37.99940936719728],[23.117532032005123,38.060645739893005],[23.210193111628243,38.129984850351256],[23.126179049640037,38.16839985297287],[23.329547814073578,38.23187349603155],[23.507981242563538,38.1605698527925],[23.634494668915384,38.21134093413555],[23.690417994252556,38.340297396049166],[24.04977480513024,38.20839666421797]]],[[[23.54765681840859,37.74754682841979],[23.49376909706481,37.67761908882199],[23.43515019705458,37.690453254360726],[23.416305312074865,37.74496111091424],[23.510552303551712,37.778337169102535],[23.54765681840859,37.74754682841979]]],[[[23.400444584654906,37.62961066042346],[23.499045217138768,37.463311175259186],[23.42441960359347,37.411701193848046],[23.423239597297492,37.45861236277308],[23.20042284595192,37.53109008579851],[23.200378691959084,37.59665284430456],[23.315190447824342,37.555725987101525],[23.338317212792933,37.63302623890957],[23.400444584654906,37.62961066042346]]],[[[23.335967587420612,35.90298650018707],[23.355299008043044,35.80099966077801],[23.276440680202676,35.82569641730335],[23.2292414416636,35.90845371245062],[23.335967587420612,35.90298650018707]]],[[[23.217136839042826,37.25367001627131],[23.15164175774086,37.20123668530127],[23.06231745766417,37.25692890886294],[23.127200349676446,37.30599785177201],[23.217136839042826,37.25367001627131]]],[[[23.07181893572937,36.26128105090274],[23.04065514872964,36.13597778207124],[22.927424503222927,36.17303821194748],[22.881811544846855,36.3280817458231],[22.9509730909978,36.37227087080982],[23.07181893572937,36.26128105090274]]]]}},{"type":"Feature","properties":{"NUTS_ID":"ES3","LEVL_CODE":1,"CNTR_CODE":"ES","NAME_LATN":"Comunidad de Madrid","NUTS_NAME":"Comunidad de Madrid","MOUNT_TYPE":null,"URBN_TYPE":null,"COAST_TYPE":null},"geometry":{"type":"MultiPolygon","coordinates":[[[[-3.539573248064193,41.1649934067361],[-3.4086432384483056,41.01996134791336],[-3.4854998476461287,40.77941830212212],[-3.344420396167477,40.64003180483917],[-3.2129377169376205,40.51012692009475],[-3.149121390170632,40.397409584745716],[-3.1683559930666934,40.28946536897639],[-3.1392408589881566,40.25140363026505],[-3.067810463076926,40.158023835980224],[-3.1614195527856634,40.064897189179966],[-3.344420396167477,40.03359108581671],[-3.686281462264779,39.97510863712122],[-3.6594242319747954,40.113588423088466],[-4.084744070060701,40.25889573973092],[-4.579075753648718,40.21719598308489],[-4.336584525853494,40.422896233074155],[-4.301553650557413,40.56649845793523],[-4.160293592790885,40.68985342103049],[-3.983231521633867,40.805004389808396],[-3.9036036008013983,40.951677755953064],[-3.539573248064193,41.1649934067361]]],[[[-3.8871519867403865,39.92624632529909],[-3.788343590100966,39.97408580579526],[-3.7136168397293887,39.93176974580969],[-3.7781741292820845,39.88140580998537],[-3.8871519867403865,39.92624632529909]]]]}},{"type":"Feature","properties":{"NUTS_ID":"BE1","LEVL_CODE":1,"CNTR_CODE":"BE","NAME_LATN":"Région de Bruxelles-Capitale/Brussels Hoofdstedelijk Gewest","NUTS_NAME":"Région de Bruxelles-Capitale/Brussels Hoofdstedelijk Gewest","MOUNT_TYPE":null,"URBN_TYPE":null,"COAST_TYPE":null},"geometry":{"type":"Polygon","coordinates":[[[4.267712689974931,50.872598180907985],[4.412653727568809,50.91493096725068],[4.506685612959286,50.783699203823836],[4.348486404765791,50.76811765500457],[4.267712689974931,50.872598180907985]]]}},{"type":"Feature","properties":{"NUTS_ID":"DE7","LEVL_CODE":1,"CNTR_CODE":"DE","NAME_LATN":"Hessen","NUTS_NAME":"Hessen","MOUNT_TYPE":null,"URBN_TYPE":null,"COAST_TYPE":null},"geometry":{"type":"Polygon","coordinates":[[[9.647755418630561,51.5525109358729],[9.587293155894386,51.36977645808557],[9.731606173188295,51.29559093132961],[9.798823686012675,51.38445904432256],[9.928338963142139,51.37529909325994],[9.968192636280476,51.305189930303634],[10.206942226407106,51.19064892684079],[10.210012784829189,51.14408295221195],[10.179671199757873,51.01311103786561],[10.021558490343093,50.99294956181277],[10.036715255685591,50.8670813060281],[9.92617638587661,50.76738984496494],[9.901707054579918,50.65454768416806],[10.056324527022028,50.66807647980926],[10.041338322107599,50.51646964531028],[9.93565476376425,50.41960648632057],[9.779706997777454,50.41133359927642],[9.732914478669795,50.3561494050944],[9.623150994189867,50.22904014503676],[9.539038080689494,50.221966120271276],[9.500834947799696,50.11373983396503],[9.404984497676686,50.087734454920295],[9.254054796325452,50.141910518996745],[8.990559952871024,50.06711914204885],[9.01608834219216,49.99134056989288],[9.050080246691861,49.86631513106891],[9.036080436875123,49.846503940221154],[9.12716974143214,49.7421345382341],[9.103005931655144,49.57745611032569],[9.082780236370734,49.526390869779185],[8.931880216254829,49.47063709610709],[8.829396804601553,49.44859844004658],[8.660167573801473,49.591729494809435],[8.581375034979233,49.51978057197996],[8.422439658308706,49.58338538413809],[8.414774248649385,49.595052067303996],[8.379512454223025,49.68444425911109],[8.446377329789346,49.730799496911274],[8.448365102087122,49.733661606242194],[8.400055244022937,49.8036751217954],[8.343030653317697,49.940506083242916],[8.288245053271023,49.995134120821355],[8.190038615008548,50.035295918878596],[8.175135317408303,50.034255559327335],[7.919991325124468,49.977382917063004],[7.7739968817059175,50.06653984017116],[8.121913464184038,50.27722512219545],[7.971559468843903,50.40622043282372],[8.012892796612558,50.52781709523122],[8.151592202170146,50.59937106709611],[8.12577663492741,50.685813924145485],[8.173119521266944,50.816438580948876],[8.355496182849985,50.8620008509352],[8.47789201131547,50.969047346847596],[8.549085223245601,51.10186802009272],[8.66346305959096,51.10865862394739],[8.739979571113771,51.183493643048415],[8.713734559757913,51.25613327725993],[8.592509388821215,51.299034045201516],[8.709272427417378,51.37183999187151],[8.915504493665638,51.395792554073715],[8.917593287805301,51.48144283893576],[8.970815080842426,51.50665555612728],[9.15541070065319,51.44267509101243],[9.440457242582909,51.65039405301296],[9.608874173583912,51.62479168300917],[9.647755418630561,51.5525109358729]]]}},{"type":"Feature","properties":{"NUTS_ID":"PT1","LEVL_CODE":1,"CNTR_CODE":"PT","NAME_LATN":"Continente","NUTS_NAME":"Continente","MOUNT_TYPE":null,"URBN_TYPE":null,"COAST_TYPE":null},"geometry":{"type":"Polygon","coordinates":[[[-8.199102370985239,41.921580077816365],[-8.165075345052886,41.81830214403827],[-8.051862725140664,41.82061392596115],[-7.734402095845957,41.902139745383586],[-7.416413120620259,41.82756413804923],[-7.200464406440068,41.87974942105253],[-7.159142738803803,41.9732184628399],[-6.985800484338817,41.97144705709407],[-6.577088063218475,41.93515745981137],[-6.516592708343892,41.6829378153394],[-6.220442953569839,41.59860634098358],[-6.330944255833637,41.39549483739135],[-6.479713167566735,41.29437983397308],[-6.689786234137169,41.20524137509888],[-6.808730905062658,41.055148113737694],[-6.929864672419192,41.02933623193005],[-6.818517442822003,40.86282399014443],[-6.800541786575826,40.361405441143546],[-6.865144205691771,40.27069454399672],[-6.951298651168082,40.25744602494104],[-7.006525336595666,40.1598825401565],[-6.878365539076545,39.975900769158066],[-7.023810304271027,39.68725015539923],[-7.5428453922710235,39.66278609437023],[-7.314967526326523,39.4559212381183],[-7.23146715964535,39.27843103932713],[-7.218372052134428,39.20881564521075],[-6.971092578397709,39.02166330738403],[-7.203134912726827,38.75101749126505],[-7.309237155162829,38.458347332335045],[-7.107952586393008,38.188121617295025],[-6.931738573373229,38.20837804629819],[-7.013750955346431,38.040794521999366],[-7.236741907093577,37.96375162873382],[-7.512691485923799,37.52625636413757],[-7.4019166340795675,37.17482748032113],[-7.401590666005703,37.17440796714365],[-7.86791918610646,36.99020192331226],[-8.17290379713967,37.08171332078304],[-8.578383849000689,37.11335773935899],[-8.957320208657018,37.01876875396891],[-8.79626545560131,37.44287863040868],[-8.79841480607261,37.86000298035961],[-8.86448083680621,37.97915628913528],[-8.735019809835094,38.51569646109195],[-9.193087863655915,38.44708668917463],[-9.232766526112263,38.660847431763585],[-9.064202529221143,38.65708272888174],[-8.92488081395387,38.75867387482483],[-8.968465854322115,38.827764846794956],[-9.03889399178601,38.85882074932459],[-9.157960612604603,38.70918348311977],[-9.454868178067493,38.70688676038977],[-9.490672837894797,38.774822020955234],[-9.416395122096077,39.05475934109591],[-9.34294951484673,39.34976195196406],[-9.093898285790297,39.57780878673903],[-9.040260313163488,39.741423033052676],[-8.89493267660395,40.04550315712524],[-8.784029168943018,40.52036505138704],[-8.69137791060093,40.68739479120263],[-8.653128772290481,40.964761520015756],[-8.776427954690508,41.47197131214439],[-8.81157411887181,41.61156754000301],[-8.871530104588585,41.86390114088049],[-8.863185838967347,41.872066462970416],[-8.602654375040176,42.053905477820564],[-8.199000324165597,42.154419064195736],[-8.100540089377496,42.03739001104973],[-8.199102370985239,41.921580077816365]]]}},{"type":"Feature","properties":{"NUTS_ID":"FRK","LEVL_CODE":1,"CNTR_CODE":"FR","NAME_LATN":"Auvergne-Rhône-Alpes","NUTS_NAME":"Auvergne-Rhône-Alpes","MOUNT_TYPE":null,"URBN_TYPE":null,"COAST_TYPE":null},"geometry":{"type":"Polygon","coordinates":[[[3.437054304448191,46.676465188209946],[3.4884780098496866,46.67302901130957],[3.6294222990140947,46.74945655387798],[3.7595087447641222,46.54188554318062],[3.9858256513585397,46.44873617422923],[3.98075324044491,46.33167595530702],[3.8995385741221087,46.27590784822993],[3.987284739958777,46.17943974813341],[4.300052026728511,46.17425261094298],[4.3880745610589384,46.21979037036297],[4.442377175604922,46.29246015104634],[4.662998301563981,46.28763861909926],[4.780208587085578,46.1766759477879],[4.945505254083201,46.49801543410411],[5.152054810105685,46.50533439535066],[5.310563706205181,46.44677012825864],[5.461086512953534,46.28382023882649],[5.64933276390804,46.317601358106515],[5.777035313557676,46.26252504881932],[5.901988396803714,46.28572612019851],[6.064002810195996,46.416229121786316],[6.145531470049953,46.367102674095854],[6.125607767702841,46.31723001977376],[5.956066776583423,46.132095506755874],[6.215235999281132,46.193952790062895],[6.2609538647127385,46.24372136688994],[6.219546989176823,46.31187792323665],[6.504427306846362,46.44980583882876],[6.82106385493709,46.42715437496177],[6.818073072302109,46.1555069099345],[7.044886013325057,45.922413071810254],[6.802368307686819,45.778562008064974],[6.980786421697825,45.62745553028456],[7.011885748287702,45.511967199992185],[7.1047229516054164,45.46845437435692],[7.164300076444394,45.39944046585757],[7.094370374605768,45.23126143316328],[6.63005092765476,45.10985657911118],[6.432318586775865,45.063861579362595],[6.260570012795203,45.12684393014327],[6.222375392341035,45.02965598334963],[6.338547260428497,44.96368172718608],[6.336628119418434,44.86895351825852],[6.134652003288405,44.85589332779286],[5.801470037258056,44.706777336794424],[5.642339328217202,44.62646650485466],[5.603889289778315,44.483944359784964],[5.453620249012885,44.454094237965066],[5.461440478819868,44.36328894318486],[5.640111324852905,44.29844159116738],[5.676036112789864,44.191428407808715],[5.4987862613991165,44.11571667491807],[5.1701717704477295,44.24039958280078],[4.981073321020829,44.41067841175064],[4.896799685441398,44.36185050106713],[4.8753581689289645,44.24603886886079],[4.650610830240015,44.32980286431363],[4.649227380685013,44.27036008007023],[4.510327262746848,44.33012392581859],[4.202216247725299,44.284441015906985],[4.084857470687226,44.33233150933888],[3.998161545012158,44.459798424062704],[3.862531048569817,44.74386590124719],[3.6324568448747714,44.86658890892447],[3.47364608878865,44.83822258774878],[3.437054304448191,44.881620323761176],[3.361347736443369,44.971408062808244],[3.0983380685823247,44.86011057279355],[3.0163265939075576,44.70866181033106],[2.981675742807614,44.644672856020236],[2.8600290571868054,44.85449440031999],[2.7273188085616495,44.921678171749086],[2.4914583728652686,44.668556014932044],[2.207472909271066,44.615529003244006],[2.062907927116348,44.97650432282127],[2.21833765983163,45.234265991054],[2.3928818017562636,45.38753165074887],[2.4752108937660435,45.39697351178487],[2.5084126401418243,45.47850134078874],[2.4921293892296807,45.737669891028446],[2.43072559505769,45.81397434893254],[2.594917112371963,45.981014227966085],[2.56537230421158,46.143036031968784],[2.2810434569050515,46.42040351282233],[2.566693258870576,46.55140263414794],[2.6958429315608443,46.71285464099466],[3.032062772608313,46.79490940085697],[3.1940421040938154,46.69270347825864],[3.437054304448191,46.676465188209946]]]}}]}
8 changes: 8 additions & 0 deletions config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"devDependencies": {
"epsg": "^0.5.0",
"fs-extra": "^11.2.0",
"reproject": "^1.2.7"
},
"dependencies": {}
}
32 changes: 15 additions & 17 deletions config/src/generate_aoi.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
const fs = require('fs-extra');
const turf = require
const reproject = require('reproject');
const epsg = require('epsg');

async function main() {
const started = Date.now();

const rawNuts = await fs.readJSON('./NUTS_RG_20M_2024_3857.geojson')
const aoi = rawNuts.features.filter(ft =>
ft.properties.NUTS_ID.includes(
'BE1',
'DE7',
'ES3',
'FRK',
'PT1',
'EL3',
'UKK'
)
)
const aoiIds = [ 'BE1', 'DE7', 'ES3', 'FRK', 'PT1', 'EL3', 'UKK' ]

await fs.writeJSON('../aoi.geojson',
{
...rawNuts,
features: aoi
const geojson = {
...rawNuts,
features: rawNuts.features
.filter(ft => ft.properties.LEVL_CODE === 1)
.filter(ft => aoiIds.includes(ft.properties.NUTS_ID))
}
)

const reprojectedGeojson = reproject.toWgs84(geojson, undefined, epsg)

await fs.writeJSON('../aoi.geojson', {
type: 'FeatureCollection',
features: reprojectedGeojson.features
})
return started;
}

Expand Down
Loading

0 comments on commit c1a3427

Please sign in to comment.