Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@mapbox/geojson-area
Advanced tools
@mapbox/geojson-area is an npm package that provides utilities for calculating the area of GeoJSON geometries. It is particularly useful for geographic data analysis and manipulation, allowing developers to easily compute the area of various GeoJSON shapes such as polygons and multipolygons.
Calculate Area of a Polygon
This feature allows you to calculate the area of a GeoJSON Polygon. The code sample demonstrates how to define a polygon and use the `geometry` method from @mapbox/geojson-area to compute its area.
const geojsonArea = require('@mapbox/geojson-area');
const polygon = {
"type": "Polygon",
"coordinates": [
[
[-122.681944, 45.520247],
[-122.681944, 45.523123],
[-122.678944, 45.523123],
[-122.678944, 45.520247],
[-122.681944, 45.520247]
]
]
};
const area = geojsonArea.geometry(polygon);
console.log(area);
Calculate Area of a MultiPolygon
This feature allows you to calculate the area of a GeoJSON MultiPolygon. The code sample demonstrates how to define a multipolygon and use the `geometry` method from @mapbox/geojson-area to compute its area.
const geojsonArea = require('@mapbox/geojson-area');
const multiPolygon = {
"type": "MultiPolygon",
"coordinates": [
[
[
[-122.681944, 45.520247],
[-122.681944, 45.523123],
[-122.678944, 45.523123],
[-122.678944, 45.520247],
[-122.681944, 45.520247]
]
],
[
[
[-122.671944, 45.510247],
[-122.671944, 45.513123],
[-122.668944, 45.513123],
[-122.668944, 45.510247],
[-122.671944, 45.510247]
]
]
]
};
const area = geojsonArea.geometry(multiPolygon);
console.log(area);
Calculate Area of a Feature Collection
This feature allows you to calculate the area of a GeoJSON Feature Collection. The code sample demonstrates how to define a feature collection and use the `geometry` method from @mapbox/geojson-area to compute its area.
const geojsonArea = require('@mapbox/geojson-area');
const featureCollection = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-122.681944, 45.520247],
[-122.681944, 45.523123],
[-122.678944, 45.523123],
[-122.678944, 45.520247],
[-122.681944, 45.520247]
]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-122.671944, 45.510247],
[-122.671944, 45.513123],
[-122.668944, 45.513123],
[-122.668944, 45.510247],
[-122.671944, 45.510247]
]
]
}
}
]
};
const area = geojsonArea.geometry(featureCollection);
console.log(area);
Turf is a powerful geospatial analysis library for JavaScript. It provides a wide range of spatial operations, including area calculations, distance measurements, and more. Compared to @mapbox/geojson-area, Turf offers a broader set of functionalities beyond just area calculations.
geojson-utils is a utility library for working with GeoJSON data. It includes functions for calculating distances, areas, and other spatial operations. While it offers similar area calculation capabilities as @mapbox/geojson-area, it also provides additional utilities for other types of spatial analysis.
geolib is a library for geospatial calculations in JavaScript. It supports a variety of operations, including distance and area calculations, bounding box computations, and more. Compared to @mapbox/geojson-area, geolib provides a more comprehensive set of geospatial tools.
Calculate the area inside of any GeoJSON geometry.
npm install @mapbox/geojson-area
var geojsonArea = require('@mapbox/geojson-area');
var area = geojsonArea.geometry(obj);
geojsonArea.geometry(obj)
Given a Geometry object, return contained
area as square meters. Invalid input will return null
.
Adapted from OpenLayers
FAQs
calculate the physical area of a geojson geometry
We found that @mapbox/geojson-area demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 107 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.