geo-faker
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

GeoFaker

Some primitives to easily generate fake but deterministic geographic data.

npm version npm downloads

Installation

npm

npm install geo-faker 

yarn

yarn add geo-faker

Why?

- for testing
- for data generation
- for data validation
- for data analysis

How?

import pointGrid from '@turf/point-grid';
import circle from '@turf/circle';
import geoFaker from 'geo-faker';
const { layer, sqrBBox } = geoFaker;

const cellSide = 10;

// creates a grid of random sized circles
const featureCollection = layer()
    .add([...pointGrid(sqrBBox([0, 0], 10), cellSide).features]) // add array of points
    .seed(42) // seed the random generator
    .addProperty('radius') // add a property "radius" to each feature with a random value between 0 and 1
    .map((i: any) => circle(i, i.properties.radius)) // create a circle from each point
    .unwarp() // unwarp the feature collection

Adding multiple fake properties

You can add multiple fake properties to each feature, by seeding the random generator with a different seed.

const featureArr = ...

const featureCollection = layer()
    .add(featuresArr) // add array of points
    .seed(42) // seed the random generator
    .addProperty('foo') // add a property to each feature with seed 42
    .seed(20) // seed the random generator again 
    .addProperty('bar') // add a property to each feature with seed 20
    .unwarp() // unwarp the feature collection

Package Sidebar

Install

npm i geo-faker

Weekly Downloads

1

Version

1.2.2

License

ISC

Unpacked Size

8.79 kB

Total Files

4

Last publish

Collaborators

  • daviteodoro