In the below example, I am using turf.intersect
to compute the intersection between Saudi Arabia and its own bounding box. So the returned polygon by turf.intersect
should be Saudi Arabia.
However, I see that the winding order of the returned polygon is reversed. What's the reason for this? If I don't want the winding order reversed, do I have to reverse the polygon's coordinates manually (in the example, I have a line commented out that calls turf.rewind to do this)?
The input saudiArabia geojson is invalid because it's wound the wrong way. According to the spec polygons must follow the right hand rule.
The winding is likely being fixed (reversed from where you're standing) at some layer within Turf to make sure the output is valid geojson.
If you don't want your result wound according to the spec, it might be of help to note Turf has a rewind() function that includes a reverse option.