Turfjs / Turfjs/turf

Split polygon by LineString

Open
#2,844 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10.5k
Forks
1k
Avg merge
1h 11m
Merged PRs (30d)
4

Description

Hey!

I am busting my head off for a few days already. So I am trying to split the polygon with the LineStrings and nothing on the internet can really help, as for what I have found is usually using the turf.union(polyLine, line) operation, which clearly is not possible. Union only works with Polygons and i have checked all the version in the past, and I haven't found the way where I could simply provide two lines to union function.
What I usually find is a process like this:

const polyAsLine = turf.polygonToLine(poly);
const unionedLines = turf.union(polyAsLine, line);
const polygonized = turf.polygonize(unionedLines);

So what is the best way to split polygon with the line?
Please help my day :D

Thanks a lot!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by checking Turf's existing polygon and line operations and determine whether a polygon-splitting API is intended; clarify the expected geometry behavior before implementation. Done would require an agreed scope, documented behavior, and tests for representative polygon and LineString inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.