Help needed for api: retireve Commune name and land usage statistics for a given coordinate

45 views
Skip to first unread message

cerve...@gmail.com

unread,
Aug 7, 2023, 3:18:25 PM8/7/23
to GeoAdminCh API
Dear experts,

I am trying to link health data with urbanization categories found at

https://www.agvchapp.bfs.admin.ch/fr/typologies/query encoded like shown in the image.

The smallest geographical unit available in this urbanization dataset is the commune name. But the health data i have, codes its geographical information in the form of X : 539384.0 and Y 151774.06 coordinates. (I do not know what encoding these coordinates correspond to but when I insert them into maps.geo.admin.ch I obtain a correct location.)

I would like to retrieve the matching commune name or commune code through the api. It  seems to be a variation of this request ?

https://api3.geo.admin.ch/rest/services/api/SearchServer?bbox=2551306.5625,1167918.328125,2551754.125,1168514.625&type=locations&sr=2056

How can I get the official commune name or commune code without later postprocessing ? The detail reply tag sometimes contains multiple names and or zip codes.

Also in a second request I would like to obtain the land use statistics based on the land coverage nomenclature NOLC04 pixel encoding the same coordinate. This is a layer in the geocatalog found on maps.geo.admin.ch

I am grateful for any assistance in building my rest queries
Thank you for your time

Jean Pierre


Capture d’écran_2023-08-07_21-05-08.png

Pascal Barth

unread,
Aug 14, 2023, 9:45:23 AM8/14/23
to geoadm...@googlegroups.com
Hello Jean-Pierre,

The coordinates you are dealing with are expressed in the old Swiss projection (LV03). To retrieve the municipality name you could run an identify request on the coordinate you have, on the ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill layer.
The only portion you then need to change, depending on your data, is the geometry param, all the others can stay the same (don't mind them and keep them as is, you could tweak the lang if you chose to). This would give you the properties of the "Commune" below the coordinate.

Then regarding the land use, I'm a bit stuck myself as the layer for land use is not the easiest to handle with identify requests. What are you searching for exactly? The type of land use at this coordinate?

Best regards,
Pascal

--
You received this message because you are subscribed to the Google Groups "GeoAdminCh API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/6c58211a-bebe-48b8-b8a9-d86ccf76d84cn%40googlegroups.com.

cerve...@gmail.com

unread,
Aug 22, 2023, 4:38:30 AM8/22/23
to GeoAdminCh API
Dear Pascal ,

Thank you very much for your reply, i will test this asap.

Regarding the second request ideally yes the land usage at this coordinate would be useful.
Is there another easier access to this data ?

Best regards and thank you
JP

Pascal Barth

unread,
Aug 22, 2023, 7:37:06 AM8/22/23
to geoadm...@googlegroups.com
Hello JP,

The problem with this layer is that the data is not stored as area on the zoom level it can be requested (see picture below, the dropped pin is the coordinate of the request from last email) but as a mesh of points, one each 100mx100m
image.png

I think I've found something that could work, but it's not straightforward :

1. Grab the coordinates you have and round them up to the closest 100s, in your case : 539384.0,151774.06 => 539400,151800 (there is a data point every 100m in each direction)
2. Transform this LV03 coordinates into LV95 by adding 2'xxx'xxx and 1'yyy'yyy to the coordinates : 539400,151800 => 2539400,1151800 (usually it would be better to calculate the equivalent with a projection tool, but here you just want the closest LV95 100s coordinates from your LV03 coordinates)
4. Sort/filter the results to find the one with the most recent survey year (they are not sorted according to that)

So a bit of coordinates transformation, and sorting, but it should work and you should have your information :-)
(You might want to change the lang of the identify request with the &lang= param)

Hope it helps,
Pascal

cerve...@gmail.com

unread,
Aug 22, 2023, 9:41:59 AM8/22/23
to GeoAdminCh API
Dear Pascal,


Thank you very much for your input, i will implement the queries you suggested. Your contribution is really appreciated. The language is not really a problem here.
Best regards and merci for providing this service

Jean-Pierre
Reply all
Reply to author
Forward
0 new messages