JSPM

random-position-in-polygon

1.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 268
  • Score
    100M100P100Q95330F
  • License MIT

Return random position inside geoJson Polygon or MultiPolygon

Package Exports

  • random-position-in-polygon

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (random-position-in-polygon) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Random position in polygon

Return random position inside geoJson Feature<(Polygon|MultiPolygon)>.

See Turf.js

Install

npm install random-position-in-polygon
# OR
yarn add random-position-in-polygon

Usage

randomPositionInPolygon(polygon: Feature<(Polygon|MultiPolygon)>): Array<number>

Params

  • polygon : geoJson Feature<PolygonMultiPolygon> or geoJson Feature<MultiPolygon>

Params

  • position : {Array<number>} Position [longitude, latitude]

Exemple

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