@turf/nearest-neighbor-analysis
Advanced tools
Comparing version 6.2.0-alpha.2 to 6.2.0-alpha.3
@@ -1,9 +0,9 @@ | ||
import area from '@turf/area'; | ||
import bbox from '@turf/bbox'; | ||
import bboxPolygon from '@turf/bbox-polygon'; | ||
import centroid from '@turf/centroid'; | ||
import distance from '@turf/distance'; | ||
import nearestPoint from '@turf/nearest-point'; | ||
import { featureEach } from '@turf/meta'; | ||
import { convertArea, featureCollection } from '@turf/helpers'; | ||
import area from "@turf/area"; | ||
import bbox from "@turf/bbox"; | ||
import bboxPolygon from "@turf/bbox-polygon"; | ||
import centroid from "@turf/centroid"; | ||
import distance from "@turf/distance"; | ||
import nearestPoint from "@turf/nearest-point"; | ||
import { featureEach } from "@turf/meta"; | ||
import { convertArea, featureCollection } from "@turf/helpers"; | ||
/** | ||
@@ -65,3 +65,3 @@ * Nearest Neighbor Analysis calculates an index based the average distances | ||
var properties = options.properties || {}; | ||
var units = options.units || 'kilometers'; | ||
var units = options.units || "kilometers"; | ||
var features = []; | ||
@@ -72,3 +72,4 @@ featureEach(dataset, function (feature) { | ||
var n = features.length; | ||
var observedMeanDistance = features.map(function (feature, index) { | ||
var observedMeanDistance = features | ||
.map(function (feature, index) { | ||
var otherFeatures = featureCollection(features.filter(function (f, i) { | ||
@@ -80,9 +81,12 @@ return i !== index; | ||
return distance(feature, nearestPoint(feature, otherFeatures).geometry.coordinates, { units: units }); | ||
}).reduce(function (sum, value) { return sum + value; }, 0) / n; | ||
var populationDensity = n / convertArea(area(studyArea), 'meters', units); | ||
}) | ||
.reduce(function (sum, value) { | ||
return sum + value; | ||
}, 0) / n; | ||
var populationDensity = n / convertArea(area(studyArea), "meters", units); | ||
var expectedMeanDistance = 1 / (2 * Math.sqrt(populationDensity)); | ||
var variance = 0.26136 / (Math.sqrt(n * populationDensity)); | ||
var variance = 0.26136 / Math.sqrt(n * populationDensity); | ||
properties.nearestNeighborAnalysis = { | ||
units: units, | ||
arealUnits: units + '²', | ||
arealUnits: units + "²", | ||
observedMeanDistance: observedMeanDistance, | ||
@@ -89,0 +93,0 @@ expectedMeanDistance: expectedMeanDistance, |
@@ -1,2 +0,2 @@ | ||
import { FeatureCollection, Feature, Polygon, Units, Properties } from '@turf/helpers'; | ||
import { FeatureCollection, Feature, Polygon, Units, Properties } from "@turf/helpers"; | ||
export interface NearestNeighborStatistics { | ||
@@ -3,0 +3,0 @@ units: Units; |
@@ -70,3 +70,3 @@ "use strict"; | ||
var properties = options.properties || {}; | ||
var units = options.units || 'kilometers'; | ||
var units = options.units || "kilometers"; | ||
var features = []; | ||
@@ -77,3 +77,4 @@ meta_1.featureEach(dataset, function (feature) { | ||
var n = features.length; | ||
var observedMeanDistance = features.map(function (feature, index) { | ||
var observedMeanDistance = features | ||
.map(function (feature, index) { | ||
var otherFeatures = helpers_1.featureCollection(features.filter(function (f, i) { | ||
@@ -85,9 +86,12 @@ return i !== index; | ||
return distance_1.default(feature, nearest_point_1.default(feature, otherFeatures).geometry.coordinates, { units: units }); | ||
}).reduce(function (sum, value) { return sum + value; }, 0) / n; | ||
var populationDensity = n / helpers_1.convertArea(area_1.default(studyArea), 'meters', units); | ||
}) | ||
.reduce(function (sum, value) { | ||
return sum + value; | ||
}, 0) / n; | ||
var populationDensity = n / helpers_1.convertArea(area_1.default(studyArea), "meters", units); | ||
var expectedMeanDistance = 1 / (2 * Math.sqrt(populationDensity)); | ||
var variance = 0.26136 / (Math.sqrt(n * populationDensity)); | ||
var variance = 0.26136 / Math.sqrt(n * populationDensity); | ||
properties.nearestNeighborAnalysis = { | ||
units: units, | ||
arealUnits: units + '²', | ||
arealUnits: units + "²", | ||
observedMeanDistance: observedMeanDistance, | ||
@@ -94,0 +98,0 @@ expectedMeanDistance: expectedMeanDistance, |
{ | ||
"name": "@turf/nearest-neighbor-analysis", | ||
"version": "6.2.0-alpha.2", | ||
"version": "6.2.0-alpha.3", | ||
"description": "turf nearest-neighbor-analysis module", | ||
@@ -27,2 +27,6 @@ "author": "Turf Authors", | ||
"module": "dist/es/index.js", | ||
"exports": { | ||
"import": "./dist/es/index.js", | ||
"require": "./dist/js/index.js" | ||
}, | ||
"types": "dist/js/index.d.ts", | ||
@@ -34,13 +38,12 @@ "sideEffects": false, | ||
"scripts": { | ||
"bench": "npm-run-all prepare bench:run", | ||
"bench:run": "node bench.js", | ||
"bench": "ts-node bench.js", | ||
"build": "npm-run-all build:*", | ||
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", | ||
"build:js": "tsc", | ||
"docs": "node ../../scripts/generate-readmes", | ||
"prepare": "npm-run-all prepare:*", | ||
"prepare:es": "tsc --outDir dist/es --module esnext --declaration false", | ||
"prepare:js": "tsc", | ||
"test": "npm-run-all prepare test:*", | ||
"test:tape": "node -r esm test.js" | ||
"test": "npm-run-all test:*", | ||
"test:tape": "ts-node -r esm test.js" | ||
}, | ||
"devDependencies": { | ||
"@turf/truncate": "^6.2.0-alpha.2", | ||
"@turf/truncate": "^6.2.0-alpha.3", | ||
"@types/tape": "*", | ||
@@ -51,2 +54,3 @@ "benchmark": "*", | ||
"tape": "*", | ||
"ts-node": "*", | ||
"tslint": "*", | ||
@@ -57,12 +61,12 @@ "typescript": "*", | ||
"dependencies": { | ||
"@turf/area": "^6.2.0-alpha.2", | ||
"@turf/bbox": "^6.2.0-alpha.2", | ||
"@turf/bbox-polygon": "^6.2.0-alpha.2", | ||
"@turf/centroid": "^6.2.0-alpha.2", | ||
"@turf/distance": "^6.2.0-alpha.2", | ||
"@turf/helpers": "^6.2.0-alpha.2", | ||
"@turf/meta": "^6.2.0-alpha.2", | ||
"@turf/nearest-point": "^6.2.0-alpha.2" | ||
"@turf/area": "^6.2.0-alpha.3", | ||
"@turf/bbox": "^6.2.0-alpha.3", | ||
"@turf/bbox-polygon": "^6.2.0-alpha.3", | ||
"@turf/centroid": "^6.2.0-alpha.3", | ||
"@turf/distance": "^6.2.0-alpha.3", | ||
"@turf/helpers": "^6.2.0-alpha.3", | ||
"@turf/meta": "^6.2.0-alpha.3", | ||
"@turf/nearest-point": "^6.2.0-alpha.3" | ||
}, | ||
"gitHead": "23d5cb91d77e0c1e2e903a2252f525797f1d0d09" | ||
"gitHead": "dce9edfc705352e8cb9e0083c9330ba0e8d77409" | ||
} |
20004
7
273
10