get object data using API

164 views
Skip to first unread message

Mahmoud Hefny

unread,
Jun 5, 2023, 7:48:39 AM6/5/23
to GeoAdminCh API
Dear geocommunity,
First off, my deepest apology if my question seems simple, but I couldn't find a direct answer here in the forum or in the AP3.geoadmin FAQs.

Simply, I need to call an API that will be based on the EGID number of a building and fetch such data (json) roof area [m2], orientation [°], and slope [°] as it shows from this https://www.uvek-gis.admin.ch/BFE/sonnendach/.

I just modified an already codepen project for my own use. Here is the link to https://codepen.io/hefnysite/pen/eYQOzbN

So far, I can click on a roof and a popup will appear, but i need to fetch this data in the backend for further analysis. 
any help. is much appreciated. 
thanks so much

Jürgen Hansmann

unread,
Jun 5, 2023, 8:03:30 AM6/5/23
to GeoAdminCh API
Dear Mahmoud,

hope I understood the problem correctly.


This would yield a response as the following:
{"results": [{"type": "Feature", "featureId": 14608274, "bbox": [2600958.4, 1197379.1, 2601019.6, 1197468.3], "layerBodId": "ch.bfe.solarenergie-eignung-daecher", "layerName": "Solarenergie: Eignung D\u00e4cher", "id": 14608274, "geometry": {"type": "MultiPolygon", "coordinates": [[[[2601019.6, 1197459.0], [2600986.7, 1197409.7], [2600986.6, 1197409.5], [2600986.5, 1197409.4], [2600967.6, 1197381.0], [2600961.6, 1197379.7], [2600959.5, 1197379.3], [2600958.4, 1197379.1], [2600958.8, 1197379.7], [2600977.4, 1197407.5], [2600980.2, 1197408.2], [2600986.3, 1197409.8], [2600985.0, 1197418.9], [2601009.8, 1197456.1], [2601017.4, 1197467.5], [2601017.9, 1197468.3], [2601019.6, 1197459.0]]]]}, "properties": {"monate": [5, 4, 3, 2, 1, 12, 11, 10, 9, 8, 7, 6], "building_id": 3622221, "a_param": [0.7755062912, 0.7098547385, 0.5661869333, 0.2962351766, 0.1693468086, 0.1022023258, 0.2048130207, 0.5336860706, 0.5859525475, 0.7479049785, 0.7395116404, 0.7636928753], "b_param": [0.7828834281, 0.6857538137, 0.6517269667, 0.7845801221, 0.8247226242, 0.7599322783, 0.8232715259, 0.7607459635, 0.9871353025, 0.7330628408, 0.7734532972, 0.3427399712], "c_param": [8.7364782054, 12.1443655420, 9.5970643450, 2.4446630563, -0.7054414921, 0.8129652661, -0.5187682017, 0.1800496568, -2.4602668217, 10.1615237373, 16.4557862477, 49.8735324584], "heizgradtage": [126.0000000000, 267.0000000000, 480.0000000000, 556.0000000000, 615.0000000000, 606.0000000000, 464.0000000000, 241.0000000000, 69.0000000000, 6.0000000000, 5.0000000000, 25.0000000000], "bedarf_heizung": 871324, "bedarf_warmwasser": 50272, "datum_aenderung": "2020-04-13T15:14:59", "datum_erstellung": "2020-04-13T15:14:59", "dg_heizung": 3, "dg_waermebedarf": 4, "duschgaenge": 89, "flaeche_kollektoren": 112.9491899234, "gstrahlung": 678655, "mstrahlung": 960, "sb_datum_aenderung": "2014-09-15T11:47:01", "sb_datum_erstellung": "2012-01-24T10:57:59", "sb_objektart": 1, "volumen_speicher": 7400, "waermeertrag": 37705, "klasse": 2, "flaeche": 706.9321895291, "ausrichtung": 124, "finanzertrag": 10858.5000000000, "stromertrag": 108585, "stromertrag_winterhalbjahr": 23567, "stromertrag_sommerhalbjahr": 85018, "monats_ertrag": [17.6297149127, 12.4874732108, 8.1545614837, 4.4122340851, 2.1971746121, 1.7767898762, 2.7226831242, 6.7009714390, 10.6547088684, 19.3592760464, 24.0719911867, 20.7952600080], "gs_serie_start": "2023-05-01T00:00:00", "klasse_text": "Mittel##Moyenne##Media##Mean##Mittel", "df_nummer": 2, "neigung": 29, "label": 14608274}}, {"type": "Feature", "featureId": 14608276, "bbox": [2600967.6, 1197371.5, 2601029.3, 1197460.7], "layerBodId": "ch.bfe.solarenergie-eignung-daecher", "layerName": "Solarenergie: Eignung D\u00e4cher", "id": 14608276, "geometry": {"type": "MultiPolygon", "coordinates": [[[[2600975.1, 1197379.5], [2600969.8, 1197371.5], [2600967.6, 1197381.0], [2600986.5, 1197409.4], [2600986.6, 1197409.5], [2600986.7, 1197409.7], [2601019.6, 1197459.0], [2601029.3, 1197460.7], [2600998.9, 1197415.1], [2600975.1, 1197379.5]]]]}, "properties": {"monate": [5, 4, 3, 2, 1, 12, 11, 10, 9, 8, 7, 6], "building_id": 3622221, "a_param": [1.1310939639, 1.2128958429, 1.3416497337, 1.3526410029, 1.1590578699, 0.9625781903, 1.1217943545, 1.2617039269, 1.3175572947, 1.1671845946, 1.1682597485, 1.1414910630], "b_param": [1.0835645655, 1.1593150021, 1.4081458119, 1.2338561988, 0.8813049573, 1.1167257750, 0.7554326416, 1.0358648915, 0.8911789105, 1.0920752780, 1.1810233032, 1.4876112557], "c_param": [-17.2283714763, -17.2802761893, -25.3206131529, -9.0542508495, 0.8581581686, -5.0151680107, 5.6903468534, -1.0748026888, -3.5323986613, -14.6793791060, -32.0803951643, -56.1406357879], "heizgradtage": [126.0000000000, 267.0000000000, 480.0000000000, 556.0000000000, 615.0000000000, 606.0000000000, 464.0000000000, 241.0000000000, 69.0000000000, 6.0000000000, 5.0000000000, 25.0000000000], "bedarf_heizung": 871324, "bedarf_warmwasser": 50272, "datum_aenderung": "2020-04-13T15:15:01", "datum_erstellung": "2020-04-13T15:15:01", "dg_heizung": 4, "dg_waermebedarf": 4, "duschgaenge": 96, "flaeche_kollektoren": 81.5266813579, "gstrahlung": 1060928, "mstrahlung": 1315, "sb_datum_aenderung": "2014-09-15T11:47:01", "sb_datum_erstellung": "2012-01-24T10:57:59", "sb_objektart": 1, "volumen_speicher": 5500, "waermeertrag": 40520, "klasse": 4, "flaeche": 806.7890507317, "ausrichtung": -56, "finanzertrag": 16974.8000000000, "stromertrag": 169748, "stromertrag_winterhalbjahr": 48033, "stromertrag_sommerhalbjahr": 121715, "monats_ertrag": [22.0799112471, 17.5109383460, 13.6995712718, 10.8999266678, 4.0618286784, 2.8367996376, 5.4151328710, 12.1489034190, 16.7504220227, 26.7599303094, 31.8410446798, 27.0881294897], "gs_serie_start": "2023-05-01T00:00:00", "klasse_text": "Sehr gut##Tr\u00e9s bonne##Molto buona##Very good##Sehr gut", "df_nummer": 4, "neigung": 27, "label": 14608276}}]}

Out of which you could filter the information you/your user needs.
Does that do the trick?

Best regards
Juergen

Mahmoud Hefny

unread,
Jun 5, 2023, 10:32:06 AM6/5/23
to GeoAdminCh API
Thanks a million, Juergen, for your prompt reply, much appreciated. 
sorry for not being clear enough in describing the problem.

In your provided example, formating this JSON using https://jsonviewer.stack.hu/, then it is easy to recognize that the result (json) doesn't have roof surface area (Roof pitch, Orientation, and Surface area). However, it has a lot of valuable information.

One of this information is the feature_Id which in your example is 14608274. Insert that ID into the sonnendach URL as follows (https://www.uvek-gis.admin.ch/BFE/sonnendach/index.html?lang=en&featureId=14608274), one can get the following (needed) results:
Your roof surface area
Roof pitch: 29°, 
Orientation: 304° Northwest
Surface area: 707 m2

Since such results are not json format, I am kindly wondering if there is an API that I can call with this feature_ID to fetch these three parameters.
Thanks so much for your help in this matter,
Best regards, Mahmoud



Jürgen Hansmann

unread,
Jun 5, 2023, 10:45:10 AM6/5/23
to GeoAdminCh API
Dear Mahmoud

Still I might be misunderstanding things, sorry!
But, at least the way I interpret the response json, all your parameters you are looking for should be contained:
The roof pitch most likely is represented by "neigung": 27 in the response json.
The Orientation could be ""ausrichtung": -56,"
And the surface area should be either "flaeche" or "flache_kollektoren", guess "flache" is the whole area of the roof or the "Parzelle" and "flache_kollektoren" the area of installed collectors?

This is my interpretation. I'll try to find if there's an official documentation for that layer around somewhere

Jürgen Hansmann

unread,
Jun 5, 2023, 10:48:36 AM6/5/23
to GeoAdminCh API
There we go: https://www.bfe.admin.ch/bfe/en/home/supply/statistics-and-geodata/geoinformation/geodata/solar-energy/suitability-of-roofs-for-use-of-solar-energy.html
Probably you know that one already.
In the first PDF there are more detailed information about the parameters in the json response

Hope that helps?
Have a nice evening
Juergen

Jürgen Hansmann

unread,
Jun 5, 2023, 10:51:38 AM6/5/23
to GeoAdminCh API
P.S.: In my example, there are 2 features returned. You can e.g. use the `tolerance` parameter to restrict or broaden the number of returned results

Mahmoud Hefny

unread,
Jun 5, 2023, 5:30:51 PM6/5/23
to GeoAdminCh API
Jürgen, I am very very grateful for your detailed solutions that keep me on track. With all the information you provided, I am now able to achieve my tasks and save myself days of work.
Wish you a very nice day (when you read my reply :) )


Jürgen Hansmann

unread,
Jun 6, 2023, 2:15:52 AM6/6/23
to GeoAdminCh API
Hi Mahmoud,

thats great to hear!

Thanks and likewise a nice day
Juergen

Reply all
Reply to author
Forward
0 new messages