-3

Hi dear StackOverflow experts, I know it may sound like a stupid question but I searched everywhere for a solution and I hope you can help me.

I have this Object which saves the coordinates of polygons relative to a worldmap with Mapbox. And my question is i have to get to the coordinates Arrays but how do I get there?

I hope you can help me :)

{
  "type": "FeatureCollection",
  "features": [
    {
      "id": "85d9515ab2c9df2f8d8c1509983d2cfa",
      "type": "Feature",
      "properties": {},
      "geometry": {
        "coordinates": [
          [
            [
              9.688465713883659,
              47.42508776635637
            ],
            [
              9.670269607933506,
              47.406270028309706
            ],
            [
              9.714558243187213,
              47.402087395494846
            ],
            [
              9.724857925803434,
              47.41463429766182
            ],
            [
              9.703915237808047,
              47.43391352359839
            ],
            [
              9.688465713883659,
              47.42508776635637
            ]
          ]
        ],
        "type": "Polygon"
      }
    }
  ]
}

1 Answers1

-1

Assuming your JSON object is YOUR_OBJECT you can get coordinates array using:

obj = YOUR_OBJECT
coords = obj.features[0].geometry.coordinates
rahool
  • 629
  • 4
  • 6
  • 1
    Thank you for this code snippet, which might provide some limited, immediate help. A [proper explanation would greatly improve its long-term value](//meta.stackexchange.com/q/114762/206345) by showing _why_ this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please [edit] your answer to add some explanation, including the assumptions you've made. – Blue Oct 20 '18 at 05:05
  • thank you for the answer. Completley overlooked that features was an array. Thank you – Cengole Oct 20 '18 at 10:41