npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

random-points-on-polygon

0.0.4 • Public • Published

random-points-on-polygon

Create n number of random points inside a polygon with TurfJS!

Install

npm install random-points-on-polygon

Usage

randomPointsOnPolygon(number, polygon, [properties], [fc])

Params

  • number: Integer - the number of random points generated
  • polygon: Feature<(Polygon|MutiPolygon)> - boundary within points are created
  • properties: Object [properties={}] - properties object assigned to each random point feature
  • fc: Boolean [fc=false] - Default returns an array of point features. When true, returns a feature collection of points

Returns

  • points: Default Array Feature<(Point)> - when fc is set to true it returns a FeatureCollection<(Points)>
Example
var randomPointsOnPolygon = require('random-points-on-polygon');
var turf = require('turf');
 
var numberOfPoints = 100;
var polygon = turf.random('polygon').features[0];
 
var points = randomPointsOnPolygon(numberOfPoints, polygon);
 
// points Array
 
//    [
//     {
//       "type": "Feature",
//       "geometry": {
//         "type": "Point",
//         "coordinates": [
//           104.92817194987191,
//           72.68912038906443
//         ]
//       },
//       "properties": {}
//     },
//     {
//       "type": "Feature",
//       "geometry": {
//         "type": "Point",
//         "coordinates": [
//           104.8246191221799,
//           72.02970325707525
//         ]
//       }
//      },
//      ...
//    ]
 
 
 

Contact

Andy B

install

npm i random-points-on-polygon

Downloadsweekly downloads

171

version

0.0.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability