Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/bbox-clip

Package Overview
Dependencies
Maintainers
9
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/bbox-clip

turf bbox-clip module

  • 7.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
9
Created

What is @turf/bbox-clip?

@turf/bbox-clip is a module from the Turf.js library that allows you to clip a GeoJSON feature to a bounding box. This is useful for tasks such as extracting a specific area from a larger dataset, ensuring that features fit within a certain geographic region, or preparing data for visualization.

What are @turf/bbox-clip's main functionalities?

Clip a Polygon to a Bounding Box

This feature allows you to clip a polygon to a specified bounding box. The code sample demonstrates how to clip a polygon that spans a larger area to fit within the bounding box defined by the coordinates [-3, 53, 3, 55].

const turf = require('@turf/turf');

const polygon = turf.polygon([[
  [-5, 52], [-5, 56], [5, 56], [5, 52], [-5, 52]
]]);
const bbox = [-3, 53, 3, 55];
const clipped = turf.bboxClip(polygon, bbox);
console.log(JSON.stringify(clipped));

Clip a LineString to a Bounding Box

This feature allows you to clip a LineString to a specified bounding box. The code sample demonstrates how to clip a LineString that spans a larger area to fit within the bounding box defined by the coordinates [-3, 53, 3, 55].

const turf = require('@turf/turf');

const line = turf.lineString([
  [-5, 52], [-5, 56], [5, 56], [5, 52]
]);
const bbox = [-3, 53, 3, 55];
const clipped = turf.bboxClip(line, bbox);
console.log(JSON.stringify(clipped));

Clip a MultiPolygon to a Bounding Box

This feature allows you to clip a MultiPolygon to a specified bounding box. The code sample demonstrates how to clip a MultiPolygon that spans a larger area to fit within the bounding box defined by the coordinates [-3, 53, 3, 55].

const turf = require('@turf/turf');

const multiPolygon = turf.multiPolygon([[
  [[-5, 52], [-5, 56], [5, 56], [5, 52], [-5, 52]]
], [
  [[-10, 50], [-10, 54], [0, 54], [0, 50], [-10, 50]]
]]);
const bbox = [-3, 53, 3, 55];
const clipped = turf.bboxClip(multiPolygon, bbox);
console.log(JSON.stringify(clipped));

Other packages similar to @turf/bbox-clip

Keywords

FAQs

Package last updated on 09 Aug 2024

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