Hello

Suppose x1, y1, ...... x4,y4 are some coordinates of a polygon. I want to generate a similar innner polygon at a offset distance of x m or km.
How can i achieve this using turf js ?
Thanks
You should be able to use the distance function to find the new corners.
Actually @turf/destination would find the new points you are looking for, @turf/distance would instead measure the distance between two points.
Alternatively you could try @turf/transform-scale, I guess using the ratio between the length of the original side and the one of the desired new side, which would automatically keep the new poligon centered on the original one.
Ah, thought of destination but copied distance link. Thanks for correcting me!
Actually
@turf/destinationwould find the new points you are looking for,@turf/distancewould instead measure the distance between two points.Alternatively you could try
@turf/transform-scale, I guess using the ratio between the length of the original side and the one of the desired new side, which would automatically keep the new poligon centered on the original one.
Okay, will try that. Let's say the offset distance is not different for each side. Then??
Huh? 馃え
Huh? 馃え
I mean let's say the distance of inner polygon from the outer polygon is different for each side. So in my original question it is 15 m. Let's say it is 10m ,5m, 15m and 8m. Will the transform/scale and distance work ?
No
No
Then what can really work in this case ?
I can't think of anything else but calculating the position of each new vertexes with @turf/destination.
Most helpful comment
Actually
@turf/destinationwould find the new points you are looking for,@turf/distancewould instead measure the distance between two points.Alternatively you could try
@turf/transform-scale, I guess using the ratio between the length of the original side and the one of the desired new side, which would automatically keep the new poligon centered on the original one.