geojson-data-generator
v1.0.7
Published
Create a number of geojson coordinates around a given coordinate (x,y) within a given area, using gaussian density model
Downloads
9
Maintainers
Readme
Table Of Contents
Instruction
geojson-data-generator
is a NodeJS module to generate a number of geojson coordinates for mapbox around a given coordinate (x,y) within a given area, using gaussian/random density model
+ output
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
24.833647854838226,
60.17639419837406
]
},
"properties": {
"id": "6.1.62"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
24.833647756069755,
60.176395260470244
]
},
"properties": {
"id": "6.1.62"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
24.833647810522173,
60.17639448821621
]
},
"properties": {
"id": "6.1.62"
}
}
]
}
### Installation
npm install geojson-data-generator --save
### Usage
+ generate a given number of points using gaussin model inside a polygon
const gGen = require('geojson-data-generator')
const p = [
24.833672907989637,
60.17639785336124
]
const area = [
{
'lng': 24.83309637450816,
'lat': 60.176830883962225
},
{
'lng': 24.833274734157925,
'lat': 60.17686561495873
},
{
'lng': 24.833331075196043,
'lat': 60.176795382134316
},
{
'lng': 24.833379271662295,
'lat': 60.17680418718882
},
{
'lng': 24.833404517424924,
'lat': 60.17677336949251
},
{
'lng': 24.833441894267708,
'lat': 60.17678005482037
},
{
'lng': 24.83378216483419,
'lat': 60.17635501829898
},
{
'lng': 24.833747537279038,
'lat': 60.176346567062296
},
{
'lng': 24.833771263567513,
'lat': 60.1763157917749
},
{
'lng': 24.833724227387364,
'lat': 60.176306155487936
},
{
'lng': 24.833782076292238,
'lat': 60.17623444647833
},
{
'lng': 24.833603982999193,
'lat': 60.17620080418433
},
{
'lng': 24.83309637450816,
'lat': 60.176830883962225
}
]
const model = gGen.densityModels.buildRandomModelPolygon(area, p[0], p[1])
const dp = gGen.genCoordsWithinPolygon(area, p[0], p[1], 50, model)
+ generate a given number of points using random model inside a circle
const gGen = require('geojson-data-generator')
const lng = 24.833217957291396, lat = 60.17680612107915
const circle = {}
circle.x = lng
circle.y = lat
circle.radius = 0.0005
const model = gGen.densityModels.buildRandomModelCircle(circle)
const p = utils.genDataPointInsideCircle(circle, lng, lat, model)