New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mapbox/geojson-area

Package Overview
Dependencies
Maintainers
107
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/geojson-area

calculate the physical area of a geojson geometry

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
107
Created

What is @mapbox/geojson-area?

@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.

What are @mapbox/geojson-area's main functionalities?

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);

Other packages similar to @mapbox/geojson-area

Keywords

FAQs

Package last updated on 19 Dec 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc