New module @turf/polygon-slice
See original GitHub issueNew module ~@turf/slice
~ @turf/polygon-slice
, currently on slice
branch
Contributions and comments are welcomed before we publish to TurfJS.
Example
var sliced = turf.polygonSlice(polygon, linestring);
Current fallbacks of PolyK
- Linestring is limited to two segments
- Coordinate precision is limited to a few decimal points.
- Output & Input is a very strange array [x1 y1, x2, y2, …]
JSDocs
/**
* Takes a {@link Polygon} and cuts it with a {@link Linestring}. Note the linestring must be a straight line (eg made of only two points).
* Properties from the input polygon will be retained on output polygons. Internally uses [polyK](http://polyk.ivank.net/) to perform split.
*
* @name slice
* @param {Feature<Polygon>} poly - single Polygon Feature
* @param {Feature<LineString>} line - single Polyline Feature
* @return {FeatureCollection<Polygon>} A FeatureCollection of polygons
*/
Input
Output
Benchmark
$ node bench.js
simple x 117,605 ops/sec ±0.57% (98 runs sampled)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:38 (18 by maintainers)
Top Results From Across the Web
Advanced geospatial analysis - Turf.js
Takes one or more features and calculates the centroid using the mean of all vertices. This lessens the effect of small islands and...
Read more >turf-polygon - npm
turf.polygon(rings, properties). Takes an array of LinearRings and optionally an Object with properties and returns a GeoJSON Polygon feature.
Read more >@turf/line-slice-along | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >Turf for Swift - Mapbox
A spatial analysis library written in Swift for native iOS, macOS, tvOS, watchOS, and Linux applications, ported from Turf.js.
Read more >How to use the @turf/union function in @turf/union - Snyk
To help you get started, we've selected a few @turf/union examples, based on popular ways it is used in public projects. ; type:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Looking for this feature! It would be useful to split polygons that are too big.
Thanks for those links @alexgleith and your work on the module, will try and take a look this evening and see if I can find a clever way around it.