I am trying to merge two turf masks into a single polygon with turf.union. However I keep getting it to return null.
My two masks look like this:
{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-75.778706,45.311839],[-75.762915,45.311839],[-75.762915,45.323789],[-75.778706,45.323789],[-75.778706,45.311839]],[[-75.786602,45.296747],[-75.722062,45.296747],[-75.722062,45.329341],[-75.786602,45.329341],[-75.786602,45.296747]]]}}
{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-75.74575,45.296747],[-75.728928,45.296747],[-75.728928,45.31715],[-75.74575,45.31715],[-75.74575,45.296747]],[[-75.786602,45.296747],[-75.722062,45.296747],[-75.722062,45.329341],[-75.786602,45.329341],[-75.786602,45.296747]]]}}
Is this possible? I've tried passing union the geojson, just the features (which is in the json I've provided), the geometry, and just the coordinates but everytime I either get an error or null.
Ideally my end goal is just to have a polygon that has multiple holes cut out of it, so if this is not the best way to do that please let me know.
Thanks!
My current work-around is by checking in the geometry.coordinates if an array does not exist in the other and pusing it in said array, then deleting the older mask and redrawing the polygon with this new added array. Works fine but seems convoluted.