Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bileljegham/randompositioninpolygon

Return random position inside geoJson Feature<(Polygon|MultiPolygon)>. (npm package)
https://github.com/bileljegham/randompositioninpolygon

geojson latitude-longitude map npm npm-package polygon position random turfjs

Last synced: about 17 hours ago
JSON representation

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

Awesome Lists containing this project

README

        

Random position in polygon
===

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

See [Turf.js](https://turfjs.org/)

## Install

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

## Usage

`randomPositionInPolygon(polygon: Feature<(Polygon|MultiPolygon)>): Array`
### Params
- `polygon` : geoJson `Feature` or geoJson `Feature`
### Params
- `position` : `{Array}` Position [longitude, latitude]

## Exemple
```js
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](https://github.com/BilelJegham/randomPositionInPolygon/blob/master/LICENSE)