Skip to content

FCF-67 API for Polygon upload

Sifeddine Biri requested to merge fcf-67-carbon-polygon into main

Description:

From a selected polygon area, POST the GeoJSON and calculate the biomass density mean across loaded carbon bands/rows for the raster of that area. Add a preliminary carbon table to load the raster along with a function to calculate the means.

To test:

  • In fcf.carbon:
(comment
  (def geojson-str "{\n    \"type\": \"FeatureCollection\",\n    \"features\": [\n        {\n            \"id\": \"1e3f442ad1fdf0d465df28a156f960f0\",\n            \"type\": \"Feature\",\n            \"properties\": {},\n            \"geometry\": {\n                \"coordinates\": [\n                    [\n                        [\n                            -122.84967654845981,\n                            38.09961099653634\n                        ],\n                        [\n                            -122.79919050594084,\n                            38.103757591881305\n                        ],\n                        [\n                            -122.79310024016037,\n                            38.06204407227444\n                        ],\n                        [\n                            -122.840321894426,\n                            38.05082236004026\n                        ],\n                        [\n                            -122.84967654845981,\n                            38.09961099653634\n                        ]\n                    ]\n                ],\n                \"type\": \"Polygon\"\n            }\n        }\n    ]\n}")
  (println "geojson " geojson-str)
  (call-sql "calculate_band_stats" geojson-str))
  • You can also POST to the API with a REST client to http://localhost:8080/carbon/polygon-calculation. JSON example:
{"geojson": {
    "type": "FeatureCollection",
    "features": [
        {
            "id": "1e3f442ad1fdf0d465df28a156f960f0",
            "type": "Feature",
            "properties": {},
            "geometry": {
                "coordinates": [
                    [
                        [
                            -122.84967654845981,
                            38.09961099653634
                        ],
                        [
                            -122.79919050594084,
                            38.103757591881305
                        ],
                        [
                            -122.79310024016037,
                            38.06204407227444
                        ],
                        [
                            -122.840321894426,
                            38.05082236004026
                        ],
                        [
                            -122.84967654845981,
                            38.09961099653634
                        ]
                    ]
                ],
                "type": "Polygon"
            }
        }
    ]
}
}
  • Or select an area with "Draw Area" from the interface and hit "Generate Data", which should print the returned result to the console.

Closes FCF-67

Edited by Sifeddine Biri

Merge request reports

Loading