Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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)
- Host: GitHub
- URL: https://github.com/bileljegham/randompositioninpolygon
- Owner: BilelJegham
- License: mit
- Created: 2020-05-15T12:46:42.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-06T14:57:02.000Z (over 1 year ago)
- Last Synced: 2024-05-01T16:11:51.036Z (7 months ago)
- Topics: geojson, latitude-longitude, map, npm, npm-package, polygon, position, random, turfjs
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/random-position-in-polygon
- Size: 347 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)