mapshaper
mapshaper copied to clipboard
How to create a particular polygon from a line of points?
Hello,
I would like to obtain a polygon from 5 points. The points of the polygon must be distant from the line formed by the 5 points of 1km as in the attached image. Do you have an idea to do this?
Many thanks
Not sure how it's related to mapshaper. You can do it using Turf JavaScript library. With it, create a line then do a buffer. You can go on https://turfjs.org, open the browser debugger, type the following code for a proof of concept.
var ordered_points = [
[
-1.5765380859375,
47.21385485500642
],
[
-1.5621185302734373,
47.20965696757036
],
[
-1.5480422973632812,
47.20487563550239
],
[
-1.5308761596679688,
47.201376826785406
],
[
-1.5140533447265625,
47.19776114868993
]
]
var line = turf.lineString(ordered_points)
var buffered = turf.buffer(line, 1, {units: 'kilometers'});
Overview of the result
Very effective, thanks for the tip.
Maybe "buffer" would be a good feature to add to Mapshaper?