Socket
Book a DemoInstallSign in
Socket

random-points-generator

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-points-generator

Random points generator

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
139
286.11%
Maintainers
1
Weekly downloads
 
Created
Source

random-points-generator

Version Downloads GitHub license code style: prettier

Generates n random points based on @turf/random.

The value added regarding @turf/random is the filter. Indeed, here points can be generated inside a GeoJSON polygon.

And it comes with :

  • a command line tool,
  • a node library,
  • a browser library

CircleCI (all branches) codecov Maintainability security status FOSSA Status

Prerequisites

  • node

Node Usage

$ npm i random-points-generator

or

yarn add random-points-generator

or

pnpm add random-points-generator

browser Usage

<script src="https://unpkg.com/random-points-generator"></script>

<script>
  const fc = geotools.random(5);
</script>

API

function random (number, options)

NameDescriptionTypeDefault
numbernumber of points to generateInteger10
optionsrandom optionsObjectundefined

returns a FeatureCollection of Points

options

OptionsDescription
bboxArray extent in [ minX, minY, maxX, maxY ] order which means (southwest lng, lat northeast lng,lat)
featuresGeoJSON polygons as features or a FeatureCollection
unkinktrue|false [Default is true] Unkink Polygon (see) before processing the features

Examples

ESM

import RandomGenerator from 'random-points-generator';

console.log(JSON.stringify(RandomGenerator.random(5)));

will output something like :

{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-57.67197760979268,42.78314165298585]}},{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[72.83765393077084,-59.52263527885765]}},{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[54.502068476617396,-60.928402442511306]}},{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-22.331900675385647,39.51543790400138]}},{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-149.45526699981158,-74.96319889821024]}}]}

CJS

const RandomGenerator = require('random-points-generator');
const points = RandomGenerator.random(3);
console.log(JSON.stringify(points));

will output something like :

{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[126.41316810428155,-47.548372609587574]},"properties":{}},{"type":"Feature","geometry":{"type":"Point","coordinates":[97.69989737806617,-47.200575920302434]},"properties":{}},{"type":"Feature","geometry":{"type":"Point","coordinates":[24.264802630637277,72.69680002654108]},"properties":{}}]}

From the command line

  • clone or fork the repo
  • cd random-points-generator
  • run npm install
  • run ./bin/random-points-generator --help to get options
Usage: bin/random-points-generator [options]

Options:
  --help, -h     Show help                                             [boolean]
  --number, -n                                                     [default: 10]
  --verbose, -v                                                 [default: false]

Examples:
  bin/random-points-generator               Generates 10 random coordinates,
                                            output to console in GeoJSON format
  bin/random-points-generator -n 1000       Generates 1000 random coordinates
  --xmin=-2 --xmax=4 --ymin=-45 --ymax=50   with these bounding box
  bin/random-points-generator -i            Generates 10 random coordinates
  world_countries.geojson                   within polygons from file
                                            world_countries.geojson

Converting to csv

TODO

Revision History

VersionDateDescription
v2.0.007/07/2025Release v2
v2.0.0-beta.301/07/2025Export default
v2.0.0-beta.230/06/2025Improves doc and upgrade deps
v2.0.0-beta.123/06/2025Refactor using TypeScript and Vitest
v1.10.023/06/2025Upgrade deps packages
v1.9.103/11/2024deps: Eslint 9 and pnpm
v1.9.029/07/2024Upgrade deps packages
v1.8.026/01/2023Adds optional unkink polygons parameter
v1.7.631/03/2021Upgrade deps packages
v1.7.522/11/2020Upgrade deps packages
v1.7.409/12/2019Upgrade deps packages
v1.7.309/12/2019Upgrade deps packages
v1.7.216/08/2019Upgrade deps packages
v1.7.116/08/2019Build removes node 6
v1.7.014/08/2019Build / test on node 10
v1.6.110/12/2018Missing Built Files
v1.6.010/12/2018Upgrade deps packages
v1.5.201/05/2018fixes unnecessary verbose message
v1.5.025/03/2018add a browser package
v1.4.020/02/2018Use single turf modules
v1.3.007/11/2017Unkink input polygons
v1.2.021/05/2017Rewrite with es6 notation
v1.1.025/04/2017Split command line and lib
v1.0.003/10/2016Creation : a tool command line

Resources

resources folder contains Large Scale Data from Natural Earth

Licensing

Licensed under the MIT License

A copy of the license is available in the repository's LICENSE file.

FOSSA Status

Keywords

random

FAQs

Package last updated on 07 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts