Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@turf/combine
Advanced tools
@turf/combine is a module from the Turf.js library that allows you to combine multiple GeoJSON features into a single feature collection. This is particularly useful for merging multiple geometries into a single collection for easier manipulation and analysis.
Combine Multiple Features
This feature allows you to combine multiple GeoJSON features (points, lines, polygons) into a single feature collection. The code sample demonstrates combining two points and a line into one feature collection.
const turf = require('@turf/turf');
const point1 = turf.point([0, 0]);
const point2 = turf.point([2, 2]);
const line = turf.lineString([[1, 1], [3, 3]]);
const combined = turf.combine(turf.featureCollection([point1, point2, line]));
console.log(JSON.stringify(combined));
The geojson-merge package allows you to merge multiple GeoJSON files into one. It is similar to @turf/combine in that it combines multiple GeoJSON features, but it is more focused on merging files rather than individual features.
The geojson-flatten package is used to flatten nested GeoJSON geometries into a single-level feature collection. While @turf/combine focuses on combining features, geojson-flatten is useful for simplifying complex nested structures.
The geojson-utils package provides a variety of utility functions for working with GeoJSON data, including combining features. It offers a broader range of functionalities compared to @turf/combine, which is specialized for combining features.
Combines a FeatureCollection of Point, LineString, or Polygon features into MultiPoint, MultiLineString, or MultiPolygon features.
Parameters
fc
FeatureCollection<(Point | LineString | Polygon)> a FeatureCollection of any typeExamples
var fc = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [19.026432, 47.49134]
}
}, {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [19.074497, 47.509548]
}
}
]
};
var combined = turf.combine(fc);
//=combined
Returns FeatureCollection<(MultiPoint | MultiLineString | MultiPolygon)> a FeatureCollection of corresponding type to input
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this module individually:
$ npm install @turf/combine
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
FAQs
turf combine module
The npm package @turf/combine receives a total of 188,211 weekly downloads. As such, @turf/combine popularity was classified as popular.
We found that @turf/combine demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.