Return random position inside geoJson Feature<(Polygon|MultiPolygon)>
.
See Turf.js
npm install random-position-in-polygon
# OR
yarn add random-position-in-polygon
randomPositionInPolygon(polygon: Feature<(Polygon|MultiPolygon)>): Array<number>
polygon
: geoJsonFeature<PolygonMultiPolygon>
or geoJsonFeature<MultiPolygon>
position
:{Array<number>}
Position [longitude, latitude]
const randomPositionInPolygon = require('random-position-in-polygon');
const polygon = `{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[
[0, 0.0], [10.0, 0.0], [10, 20],
[0.0, 20], [0, 0.0] ]]
}
}`
const positionRandom = randomPositionInPolygon(JSON.parse(polygon))
under MIT license