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

@turf/mask

Package Overview
Dependencies
Maintainers
9
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/mask

turf mask module

  • 7.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
671K
increased by6.5%
Maintainers
9
Weekly downloads
 
Created

What is @turf/mask?

@turf/mask is a module in the Turf.js library that allows you to create a mask from a polygon. This mask can be used to clip or hide parts of other geometries that fall outside the polygon. It is particularly useful in geospatial analysis for focusing on specific areas of interest.

What are @turf/mask's main functionalities?

Create a Mask

This feature allows you to create a mask from a given polygon. The mask can then be used to clip other geometries, effectively hiding parts of them that fall outside the polygon.

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

const polygon = turf.polygon([[
  [-5, 52],
  [-4, 52],
  [-4, 53],
  [-5, 53],
  [-5, 52]
]]);

const mask = turf.mask(polygon);
console.log(JSON.stringify(mask));

Clip Geometry with Mask

This feature demonstrates how to use the mask to clip a line geometry. The resulting geometry will only include the parts of the line that fall within the mask polygon.

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

const polygon = turf.polygon([[
  [-5, 52],
  [-4, 52],
  [-4, 53],
  [-5, 53],
  [-5, 52]
]]);
const mask = turf.mask(polygon);

const line = turf.lineString([[-6, 51], [-3, 54]]);
const clipped = turf.mask(line, mask);
console.log(JSON.stringify(clipped));

Other packages similar to @turf/mask

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