Calculating a total area using coordinates passed from a json file
Afficher commentaires plus anciens
I am trying to calculate a total area using coordinates passed from a json file. I wrote these lines given below to pass them to Matlab and it works fine. The problem is I couldn't figure out how to extract the coordinates correctly and use them to calculate the total area. Any advice? Any built-in function i can use?
jsonFile = 'myfile.json';
jsonStr = fileread(jsonFile);
jsonData = jsondecode(jsonStr);
Here is a sample from the json file:
{"type":"FeatureCollection","name":"myfile","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}},"features":[{"type":"Feature","properties":{"GID_0":"GEO","COUNTRY":"Georgia"},"geometry":{"type":"MultiPolygon","coordinates":[[[[43.8995,41.1648],[43.8862,41.164],[43.8532,41.1663],[43.8445,41.1655],[43.8229,41.1583],[43.789,41.1408],[43.7769,41.1372],[43.7699,41.1329],[43.7505,41.1136],[43.7448,41.1116],[43.7297,41.1138],[43.7062,41.1219],[43.6921,41.1312],[43.6755,41.1382],[43.6671,41.1375],[43.6525,41.1301],[43.6367,41.1254],[43.6134,41.1255],[43.5746,41.1475],[43.5656,41.1494],[43.5413,41.1489],[43.4903,41.1295],[43.4711,41.1295],[43.4629,41.1413],[43.4555,41.161],[43.451,41.1672],[43.4372,41.1794],[43.4052,41.1882],[43.3841,41.1995],[43.3747,41.2019],[43.3554,41.2012],[43.2744,41.1816],[43.248,41.1774],[43.2265,41.1761],[43.2336,41.1873],[43.2318,41.1927],[43.1981,41.2475],[43.1921,41.2521],[43.176,41.2547],[43.1533,41.2456],[43.1315,41.2497],[43.1239,41.2541],[43.1282,41.2575],[43.1406,41.263],[43.1594,41.2682],[43.1749,41.275],[43.188,41.2851]
Réponses (1)
Adam Danklefsen
le 18 Mai 2023
0 votes
Try the Shoelace Method
Catégories
En savoir plus sur JSON Format dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!