Comments (4)
These two polygons don't seem to be valid geojson, the first and last coordinates should have the same values to close the polygon ring.
Is the input to your earlier steps to produce the masks valid?
Separately, the difference function can be used to subtract out polygons from a larger polygon to produce holes but I'm not sure what your use case is.
from turf.
These are two polygons each with a hole cut out it, with the "base" polygon remaining the same and then two different "cut" polygons. The base polygon is the same in both in geometry.coordinates[1]:
[[-75.786602,45.296747],[-75.722062,45.296747],[-75.722062,45.329341],[-75.786602,45.329341],[-75.786602,45.296747]]
The actual geoJSON is a FeatureCollection:
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-75.748839,45.300249],[-75.730129,45.300249],[-75.730129,45.31534],[-75.748839,45.31534],[-75.748839,45.300249]],[[-75.777677,45.293486],[-75.717599,45.293486],[-75.717599,45.320289],[-75.777677,45.320289],[-75.777677,45.293486]]]}}]}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-75.777677,45.307251],[-75.755534,45.307251],[-75.755534,45.320289],[-75.777677,45.320289],[-75.777677,45.307251]],[[-75.777677,45.293486],[-75.717599,45.293486],[-75.717599,45.320289],[-75.777677,45.320289],[-75.777677,45.293486]]]}}]}
The masks are correct as I am displaying them propely on my leaflet map, just these two are seperate and I wish to merge them into one.
from turf.
Hi @rjbrockbundy. Ran your geojson through a validator and get an error about the "right hand rule". So it might be that the direction of one of your rectangles is incorrect (these both run clockwise):
Tools like Turf use the direction (or winding) of the polygon to figure out which side is meant to be the outside. It might look ok in Leaflet because they have some extra checks to try to give you something that looks good.
Try running your polygons through turf-rewind, and it should change it to the below (outer ring is now anticlockwise):
Give that a try and let us know if it helps. If not, we can dig a little further.
A good (strict) geojson validator: https://geojsonlint.com/
from turf.
Closing for now in lieu of further feedback. Feel free to reopen if the suggestion above doesn't solve the problem.
from turf.
Related Issues (20)
- Errors that occur when judging between points and polygon for data with inner rings HOT 1
- FeatureCollection (type) not longer exported form @turf/turf (alpha 7.0.0) HOT 2
- lineOverlap does not recognize partially overlaps HOT 1
- Typings doesn't work when `moduleResolution` is `bundler` HOT 4
- lineOverlap tolerance is not handled in every case
- turf.centerOfMass for multiple polygons in Feature Collection HOT 2
- booleanIntersects false positive for self-intersecting lines HOT 2
- [Bug report]: ts declaration broken HOT 2
- Could not find a declaration file for module '@turf/turf'. HOT 3
- booleanContains doesn't get good result when detect an unusual polygon HOT 1
- Typescript typing error when import "@turf/turf" HOT 2
- Can coordinate system parameters be added to some conversion methods?
- Drawing a curved line from Point A to Point B HOT 1
- Could not find a declaration file for module '@turf/mask' HOT 3
- There was a loss of accuracy when using the turf.intersect function
- BooleanWithin does not work correctly with (Island polygon / Doughnut).
- Property 'booleanPointInPolygon' does not exist on type 'TurfStatic' HOT 1
- isobands generating countered some wrong results HOT 3
- Broken TS types HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from turf.