How to use the @turf/random function in @turf/random

To help you get started, we’ve selected a few @turf/random examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DAVFoundation / community / src / lib / dummyData.js View on Github external
count: 306,
      bbox: [-6.13,50.45,1.46,57.29]
    }
  ];

  let points = await DummyData.find({}).exec();

  if(points.length>200){
    return;
  }

  let allPoints = [];

  for(var region in boundingBoxes){
    //let points = random.point(230, region.bbox);
    let points = turf('points', boundingBoxes[region].count, {
      bbox: boundingBoxes[region].bbox
    });

    for(var index in points.features){
      let obj = {"loc":points.features[index].geometry};
      allPoints.push(obj); // contains geojson point obj which can be saved in mongoose
    }
  }

  console.log(allPoints[0].loc.coordinates);

  DummyData.insertMany(allPoints)
    .then(docs => {
      console.log(`Added ${docs.length} geo points`);
    })
    .catch(err => {
github Turfjs / turf / packages / turf-isolines / types.ts View on Github external
import random from '@turf/random'
import isolines from './'

const points = random('point', 100, {
    bbox: [0, 30, 20, 50]
})
for (let i = 0; i < points.features.length; i++) {
    points.features[i].properties.z = Math.random() * 10;
}
const breaks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const lines = isolines(points, breaks, 'temperature')
const properties = {apply: 'all'}

// Properties option
isolines(points, breaks, 'temperature', properties)
isolines(points, breaks, 'temperature', properties, [{name: 'break1'}, {name: 'break2'}])
github wbkd / making-maps-with-react / src / helper / utils.js View on Github external
latlng: [52.499040, 13.418392]
  }, {
    name: 'Görlitzer Park',
    latlng: [52.496912, 13.436738]
  }, {
    name: 'webkid',
    latlng: [52.501106, 13.422061]
  }
];

export const mapConfig = {
  center: [52.499219, 13.425416],
  zoom: 8
};

const points = turfRandom('points', 50000, { bbox: [13.0535, 52.3303, 13.7262, 52.6675] });
export const locations = Immutable.fromJS(points.features.map(feat => feat.geometry.coordinates));


export const scatterPlotData = points.features.map(feat => (
  { position: feat.geometry.coordinates,
    radius: 1,
    color: [255, 0, 0]
  }
));

export function getColor(d) {
  const z = d.start[2];
  const r = z / 10000;

  return [255 * ((1 - r) * 2), 128 * r, 255 * r, 255 * (1 - r)];
}

@turf/random

turf random module

MIT
Latest version published 1 month ago

Package Health Score

98 / 100
Full package analysis