Search code examples
javascriptnode.jsreactjsmapboxdeck.gl

Calculate area & perimeter of a geojson feature of GeojsonLayer in deck.gl


I am using deck.gl to render a geojsonlayer using their geojsonlayer function, where the source of data is a geojson file.

Now I want display an infowindow to show area & perimeter of each feature, when clicked on them on the map. I have managed to fetch the properties object of a particular feature and show its reverse geocode address and display them in the infoWindow (pic below), enter image description here

which also gives me access to the geofence coordinates of that particular feature. But I am not able to find any function from the documentation that allows us to calculate the area. Is there anything I missed here? Or Do I have to calculate it manually based on cartesian space and spheroid?


Solution

  • I found turf.js that does the job for calculating area and perimeter of a geojson feature.