Turf: Get coordinates of inner polygon at a offset distance from x m or km

Created on 25 Jan 2021  路  9Comments  路  Source: Turfjs/turf

Hello

image

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

question

Most helpful comment

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.

All 9 comments

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/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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dhivehi picture dhivehi  路  5Comments

stebogit picture stebogit  路  5Comments

morganherlocker picture morganherlocker  路  5Comments

stebogit picture stebogit  路  5Comments

robhawkes picture robhawkes  路  3Comments