Skip to content

Commit c823eed

Browse files
committed
- add placeholder shp parse for missing federal states, as a check reveiled that all of their GIS systems support shp export with various projections
- add support for more projections with additional query parameter - update readme - update version
1 parent 9ca1d23 commit c823eed

File tree

9 files changed

+228
-39
lines changed

9 files changed

+228
-39
lines changed

README.md

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,42 @@
11
# harmonie :seedling:
2-
*harmonie* is a software package that harmonizes IACS (ZID) files of all German federal states. With *harmonie*, you can outsource parsing of the different direct payment application files, so you can rely on a given input data structure.
2+
*harmonie* is a software package that harmonizes farm subsidy application files of all German federal states.
3+
It takes the various xml, gml, shp, and dbf files issued by the federal farm subsidy application softwares, and converts them into **WGS84** projected
4+
GeoJSON geometries suitable for any web mapping service.
5+
6+
With *harmonie*, you can outsource parsing of the different direct payment application files, so you can rely on a given input data structure.
37

48
*harmonie*
59
- ✅ works in the browser/Node.js
610
- ✅ adheres to the [agroJSON](https://github.com/fruchtfolge/agroJSON) specification
711
- ✅ is open source (MIT license)
812

9-
This repository is **WIP**, APIs and data structures are likely to change.
10-
Currently, **9/16** federal states are supported.
13+
14+
Converting the geometries (fields) contained in the application files is supported for **all** federal states in Germany.
15+
For most federal states, additional information as the primary crop cultivated on a field, as well as the [fieldblock number (FLIK)](https://de.wikipedia.org/wiki/Feldblock) are obtained as well.
16+
1117
The following overview table displays the current state of the project:
1218

13-
| Federal state | ISO 3166-2 code | Test data available? | Supported by 'harmonie' | ToDos |
14-
|:-----------------------|:----------------|:---------------------|:------------------------|:-----------------------------------------------|
15-
| Brandenburg | DE-BB ||| - |
16-
| Berlin | DE-BE ||| - |
17-
| Baden-Württemberg | DE-BW ||| - |
18-
| Bayern | DE-BY ||| - |
19-
| Bremen | DE-HB | ⬜️ | ⬜️ | Waiting on test data (ANDI NDS) |
20-
| Hessen | DE-HE ||| - |
21-
| Hamburg | DE-HH | ⬜️ | ⬜️ | Waiting on test data (ANDI NDS) |
22-
| Mecklenburg-Vorpommern | DE-MV ||| - |
23-
| Niedersachsen | DE-NI | ⬜️ | ⬜️ | Waiting on test data (ANDI NDS) |
24-
| Nordrhein-Westfalen | DE-NW ||| - |
25-
| Rheinland-Pfalz | DE-RP || ⬜️ | Create property mapping |
26-
| Schleswig-Holstein | DE-SH | ⬜️ | ⬜️ | Waiting on test data (ELSA Schleswig-Holstein) |
27-
| Saarland | DE-SL ||| - |
28-
| Sachsen | DE-SN | ⬜️ | ⬜️ | Waiting on test data (DIANAweb Sachsen-Anhalt) |
29-
| Sachsen-Anhalt | DE-ST | ⬜️ | ⬜️ | Waiting on test data (ELAISA Sachsen) |
30-
| Thüringen | DE-TH ||| - |
19+
✅ Federal states fully supported by 'harmonie': Plot geometries, including crop cultivation code and FLIK are obtained.
20+
☑️ Federal states partially supported by 'harmonie': Only plot geometries are obtained.
21+
22+
| Federal state | ISO 3166-2 code | Subsidy application program | Test data available? | Supported by 'harmonie' | ToDos |
23+
|:-----------------------|:----------------|:-----------------------------------------------------------------------------------------------------------------------------------------|:---------------------|:------------------------|:-----------------------------------------------|
24+
| Brandenburg | DE-BB | [WebClient Agrarantrag BB](https://www.agrarantrag-bb.de/webClient_BB_P/) ||| - |
25+
| Berlin | DE-BE | [WebClient Agrarantrag BB](https://www.agrarantrag-bb.de/webClient_BB_P/) ||| - |
26+
| Baden-Württemberg | DE-BW | [FIONA - Flächeninformation und Online-Antrag](https://fiona.landbw.de/fiona/pages/login.xhtml) ||| - |
27+
| Bayern | DE-BY | [iBalis Bayern](https://www.stmelf.bayern.de/ibalis/hRPSYCJ9iai73RtXboYewXCBR-_cYW-D/hRPf5) ||| - |
28+
| Bremen | DE-HB | [ANDI - Agrarförderung Niedersachsen Digital](https://sla.niedersachsen.de/andi-web/) | ⬜️ | ☑️ | Waiting on test data (ANDI NDS) |
29+
| Hessen | DE-HE | [Antragsmappe der WI-Bank](https://www.wibank.de/wibank/direktzahlungen) ||| - |
30+
| Hamburg | DE-HH | [ANDI - Agrarförderung Niedersachsen Digital](https://sla.niedersachsen.de/andi-web/) | ⬜️ | ☑️ | Waiting on test data (ANDI NDS) |
31+
| Mecklenburg-Vorpommern | DE-MV | [WebClient Agrarantrag MV](https://online.agrarantrag-mv.de/webClient_MV_P/) ||| - |
32+
| Niedersachsen | DE-NI | [ANDI - Agrarförderung Niedersachsen Digital](https://sla.niedersachsen.de/andi-web/) | ⬜️ | ☑️ | Waiting on test data (ANDI NDS) |
33+
| Nordrhein-Westfalen | DE-NW | [ELAN-NRW WebClient](https://www.elan-nrw.de/webClient_NW/#docs) ||| - |
34+
| Rheinland-Pfalz | DE-RP | [eAntrag](https://www.dlr.rlp.de/Internet/global/inetcntr.nsf/dlr_web_full.xsp?src=6F7G9TYH1A&p1=IT5HUS52Z8&p3=SXP6I7GS55&p4=JM94D5V1SK) || ☑️ | Create property mapping |
35+
| Schleswig-Holstein | DE-SH | [WebClient Agrarantrag SH](https://www.sammelantrag-sh.dataport.de/webClient_SH_P/SHWebClient.html) | ⬜️ | ☑️ | Waiting on test data (ELSA Schleswig-Holstein) |
36+
| Saarland | DE-SL | [ASdigital Saarland](https://www.saarland.de/126854.htm) ||| - |
37+
| Sachsen | DE-SN | [DianaWeb WebClient SN](https://www.diana.sachsen.de/webClient_SN_P/#login) | ⬜️ | ☑️ | Waiting on test data (DIANAweb Sachsen) |
38+
| Sachsen-Anhalt | DE-ST | [ELAISA WebClient ST](https://www.inet17.sachsen-anhalt.de/webClient_ST_P/) | ⬜️ | ☑️ | Waiting on test data (ELAISA Sachsen-Anhalt) |
39+
| Thüringen | DE-TH | [Verona Thüringen](https://verona.thueringen.de/#) ||| - |
3140

3241
## Installation
3342

@@ -80,8 +89,9 @@ Returns an array of objects containing individual parts of fields (German: *Teil
8089
- `gml` *\<string, UTF-8\>*
8190
- `shp` *\<blob\>*
8291
- `dbf` *\<blob\>*
92+
- `projection` *\<string, UTF-8\> optional for shp and dbf request, can be specified when the input files are not EPSG:25832*
8393

84-
Sample minimum return value:
94+
Sample return value:
8595
```js
8696
[{
8797
id: 'harmonie_runningIndex_FieldBlockNumber', // e.g. 'harmonie_36_DEBBLI0261009129'
@@ -112,17 +122,17 @@ the federal state:
112122
| Berlin | DE-BE | state, xml |
113123
| Baden-Württemberg | DE-BW | state, xml, shp, dbf |
114124
| Bayern | DE-BY | state, xml |
115-
| Bremen | DE-HB | state, - |
125+
| Bremen | DE-HB | state, shp, dbf |
116126
| Hessen | DE-HE | state, shp, dbf |
117-
| Hamburg | DE-HH | state, - |
127+
| Hamburg | DE-HH | state, shp, dbf |
118128
| Mecklenburg-Vorpommern | DE-MV | state, xml |
119-
| Niedersachsen | DE-NI | state, - |
129+
| Niedersachsen | DE-NI | state, shp, dbf |
120130
| Nordrhein-Westfalen | DE-NW | state, xml, gml |
121-
| Rheinland-Pfalz | DE-RP | state, - |
122-
| Schleswig-Holstein | DE-SH | state, - |
131+
| Rheinland-Pfalz | DE-RP | state, shp, dbf |
132+
| Schleswig-Holstein | DE-SH | state, shp, dbf |
123133
| Saarland | DE-SL | state, shp, dbf |
124-
| Sachsen | DE-SN | state, - |
125-
| Sachsen-Anhalt | DE-ST | state, - |
134+
| Sachsen | DE-SN | state, shp, dbf |
135+
| Sachsen-Anhalt | DE-ST | state, shp, dbf |
126136
| Thüringen | DE-TH | state, shp, dbf |
127137

128138
## Specifics for certain federal states

dist/harmonie.cjs.js

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ proj4.defs('EPSG:5650', '+proj=tmerc +lat_0=0 +lon_0=15 +k=0.9996 +x_0=33500000
3131
proj4.defs('EPSG:31467', '+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs');
3232
// DE-SL
3333
proj4.defs('EPSG:31462', '+proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs');
34+
// others
35+
proj4.defs('EPSG:31468', '+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs');
36+
proj4.defs('EPSG:25833', '+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs');
37+
proj4.defs('EPSG:4647', '+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=32500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
3438

3539
const fromETRS89 = new proj4.Proj('EPSG:25832');
3640
const toWGS84 = new proj4.Proj('WGS84');
@@ -438,6 +442,44 @@ async function bb$1 (query) {
438442
return helpers.groupByFLIK(plots)
439443
}
440444

445+
async function sl (query) {
446+
const incomplete = queryComplete(query, ['shp', 'dbf']);
447+
if (incomplete) throw new Error(incomplete)
448+
// if a projection was passed, check if it is supported
449+
const supportedProjs = ['EPSG:25832', 'EPSG:5650', 'EPSG:31467', 'EPSG:31462', 'EPSG:31468', 'EPSG:25833', 'EPSG:4647'];
450+
if (query.projection && supportedProjs.indexOf(query.projection) === -1) {
451+
throw new Error(`Projection ${query.projection} is not supported by harmonie. The supported projections are: ${supportedProjs}`)
452+
}
453+
// parse the shape file information
454+
const geometries = await parse.shape(query.shp, query.dbf);
455+
// reproject coordinates into web mercator
456+
geometries.features = geometries.features.map(f => helpers.reprojectFeature(f, query.projection));
457+
458+
// as we don't know anything about the structure of the shape files,
459+
// we just make some assumptions based on the following information
460+
//
461+
const subplots = geometries.features.map((plot, count) => new Field({
462+
id: `harmonie_${count}_${plot.properties.FLIK}`,
463+
referenceDate: plot.properties.ANTJAHR,
464+
NameOfField: '',
465+
NumberOfField: count,
466+
Area: plot.properties.AKT_FL,
467+
FieldBlockNumber: plot.properties.FLIK,
468+
PartOfField: '',
469+
SpatialData: plot,
470+
Cultivation: {
471+
PrimaryCrop: {
472+
CropSpeciesCode: plot.properties.KC_GEM,
473+
Name: undefined
474+
}
475+
}
476+
}));
477+
478+
// finally, group the parts of fields by their FLIK and check whether they are
479+
// actually seperate parts of fields
480+
return helpers.groupByFLIK(subplots)
481+
}
482+
441483
async function nw (query) {
442484
const incomplete = queryComplete(query, ['xml', 'gml']);
443485
if (incomplete) throw new Error(incomplete)
@@ -472,7 +514,7 @@ async function nw (query) {
472514
return helpers.groupByFLIK(plots)
473515
}
474516

475-
async function sl (query) {
517+
async function sl$1 (query) {
476518
const incomplete = queryComplete(query, ['shp', 'dbf']);
477519
if (incomplete) throw new Error(incomplete)
478520
// parse the shape file information
@@ -502,7 +544,7 @@ async function sl (query) {
502544
return helpers.groupByFLIK(subplots)
503545
}
504546

505-
async function sl$1 (query) {
547+
async function sl$2 (query) {
506548
const incomplete = queryComplete(query, ['shp', 'dbf']);
507549
if (incomplete) throw new Error(incomplete)
508550
// parse the shape file information
@@ -541,20 +583,36 @@ function harmonie (query) {
541583
switch (state) {
542584
case 'DE-BB':
543585
return bb(query)
586+
case 'DE-BE':
587+
return bb(query)
544588
case 'DE-BW':
545589
return bw(query)
546590
case 'DE-BY':
547591
return bw$1(query)
592+
case 'DE-HB':
593+
return sl(query)
548594
case 'DE-HE':
549595
return he(query)
596+
case 'DE-HH':
597+
return sl(query)
550598
case 'DE-MV':
551599
return bb$1(query)
600+
case 'DE-NI':
601+
return sl(query)
552602
case 'DE-NW':
553603
return nw(query)
604+
case 'DE-RP':
605+
return sl(query)
606+
case 'DE-SH':
607+
return sl(query)
554608
case 'DE-SL':
609+
return sl$1(query)
610+
case 'DE-SN':
611+
return sl(query)
612+
case 'DE-ST':
555613
return sl(query)
556614
case 'DE-TH':
557-
return sl$1(query)
615+
return sl$2(query)
558616
default:
559617
throw new Error(`No such state as "${state}" according to ISO 3166-2 in Germany."`)
560618
}

dist/harmonie.esm.js

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ proj4.defs('EPSG:5650', '+proj=tmerc +lat_0=0 +lon_0=15 +k=0.9996 +x_0=33500000
2727
proj4.defs('EPSG:31467', '+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs');
2828
// DE-SL
2929
proj4.defs('EPSG:31462', '+proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs');
30+
// others
31+
proj4.defs('EPSG:31468', '+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs');
32+
proj4.defs('EPSG:25833', '+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs');
33+
proj4.defs('EPSG:4647', '+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=32500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
3034

3135
const fromETRS89 = new proj4.Proj('EPSG:25832');
3236
const toWGS84 = new proj4.Proj('WGS84');
@@ -434,6 +438,44 @@ async function bb$1 (query) {
434438
return helpers.groupByFLIK(plots)
435439
}
436440

441+
async function sl (query) {
442+
const incomplete = queryComplete(query, ['shp', 'dbf']);
443+
if (incomplete) throw new Error(incomplete)
444+
// if a projection was passed, check if it is supported
445+
const supportedProjs = ['EPSG:25832', 'EPSG:5650', 'EPSG:31467', 'EPSG:31462', 'EPSG:31468', 'EPSG:25833', 'EPSG:4647'];
446+
if (query.projection && supportedProjs.indexOf(query.projection) === -1) {
447+
throw new Error(`Projection ${query.projection} is not supported by harmonie. The supported projections are: ${supportedProjs}`)
448+
}
449+
// parse the shape file information
450+
const geometries = await parse.shape(query.shp, query.dbf);
451+
// reproject coordinates into web mercator
452+
geometries.features = geometries.features.map(f => helpers.reprojectFeature(f, query.projection));
453+
454+
// as we don't know anything about the structure of the shape files,
455+
// we just make some assumptions based on the following information
456+
//
457+
const subplots = geometries.features.map((plot, count) => new Field({
458+
id: `harmonie_${count}_${plot.properties.FLIK}`,
459+
referenceDate: plot.properties.ANTJAHR,
460+
NameOfField: '',
461+
NumberOfField: count,
462+
Area: plot.properties.AKT_FL,
463+
FieldBlockNumber: plot.properties.FLIK,
464+
PartOfField: '',
465+
SpatialData: plot,
466+
Cultivation: {
467+
PrimaryCrop: {
468+
CropSpeciesCode: plot.properties.KC_GEM,
469+
Name: undefined
470+
}
471+
}
472+
}));
473+
474+
// finally, group the parts of fields by their FLIK and check whether they are
475+
// actually seperate parts of fields
476+
return helpers.groupByFLIK(subplots)
477+
}
478+
437479
async function nw (query) {
438480
const incomplete = queryComplete(query, ['xml', 'gml']);
439481
if (incomplete) throw new Error(incomplete)
@@ -468,7 +510,7 @@ async function nw (query) {
468510
return helpers.groupByFLIK(plots)
469511
}
470512

471-
async function sl (query) {
513+
async function sl$1 (query) {
472514
const incomplete = queryComplete(query, ['shp', 'dbf']);
473515
if (incomplete) throw new Error(incomplete)
474516
// parse the shape file information
@@ -498,7 +540,7 @@ async function sl (query) {
498540
return helpers.groupByFLIK(subplots)
499541
}
500542

501-
async function sl$1 (query) {
543+
async function sl$2 (query) {
502544
const incomplete = queryComplete(query, ['shp', 'dbf']);
503545
if (incomplete) throw new Error(incomplete)
504546
// parse the shape file information
@@ -537,20 +579,36 @@ function harmonie (query) {
537579
switch (state) {
538580
case 'DE-BB':
539581
return bb(query)
582+
case 'DE-BE':
583+
return bb(query)
540584
case 'DE-BW':
541585
return bw(query)
542586
case 'DE-BY':
543587
return bw$1(query)
588+
case 'DE-HB':
589+
return sl(query)
544590
case 'DE-HE':
545591
return he(query)
592+
case 'DE-HH':
593+
return sl(query)
546594
case 'DE-MV':
547595
return bb$1(query)
596+
case 'DE-NI':
597+
return sl(query)
548598
case 'DE-NW':
549599
return nw(query)
600+
case 'DE-RP':
601+
return sl(query)
602+
case 'DE-SH':
603+
return sl(query)
550604
case 'DE-SL':
605+
return sl$1(query)
606+
case 'DE-SN':
607+
return sl(query)
608+
case 'DE-ST':
551609
return sl(query)
552610
case 'DE-TH':
553-
return sl$1(query)
611+
return sl$2(query)
554612
default:
555613
throw new Error(`No such state as "${state}" according to ISO 3166-2 in Germany."`)
556614
}

dist/harmonie.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"main": "dist/harmonie.cjs.js",
55
"module": "dist/harmonie.esm.js",
66
"browser": "dist/harmonie.min.js",
7-
"description": "Harmonizes IACS (ZID) files of all German Federal States",
7+
"description": "Farm subsidy application files of all German federal states",
88
"directories": {
99
"test": "test"
1010
},

0 commit comments

Comments
 (0)