j
j
jsGeoDa
Search
K

jsgeoda

Methods

azpGreedy(weights, k, values, inits, initRegion, minBoundValues, minBounds, maxBoundValues, maxBounds, scaleMethod, distanceMethod, seed) → {Object}
A greedy algorithm to solve the AZP problem.
A greedy algorithm to solve the AZP problem
Parameters:
Name
Type
Description
weights
WeightsResult
The weights object WeightsResult
k
Number
The number of spatially constrained clusters
values
Array
The list of numeric vectors of selected variable.
inits
Number
The number of construction re-runs, which is for ARiSeL "automatic regionalization with initial seed location"
initRegion
Array
The initial regions that the local search starts with. Default is empty. means the local search starts with a random process to "grow" clusters
minBoundValues
Array
The list of numeric array of selected minimum bounding variables.
minBounds
Array
The list of minimum value that the sum value of bounding variables in each cluster should be greater than.
maxBoundValues
Array
The list of numeric array of selected maximum bounding variables.
maxBounds
Array
The list of minimum value that the sum value of bounding variables in each cluster should be less than.
scaleMethod
String
The scaling methods {'raw', 'standardize', 'demean', 'mad', 'range_standardize', 'range_adjust'}. Defaults to 'standardize'.
distanceMethod
String
The distance methods {"euclidean", "manhattan"}. Defaults to 'euclidean'.
seed
Number
The seed for random number generator.
Source:
Returns:
Return a ClusteringResult object: {'total_ss', 'within_ss', 'between_ss', 'ratio', 'clusters'}TypeObject
azpSA(weights, k, values, coolingRate, saMaxIt, inits, initRegion, minBoundValues, minBounds, maxBoundValues, maxBounds, scaleMethod, distanceMethod, seed) → {Object}
A simulated annealing algorithm to solve the AZP problem.
A simulated annealing algorithm to solve the AZP problem
Parameters:
Name
Type
Description
weights
WeightsResult
The weights object WeightsResult
k
Number
The number of spatially constrained clusters
values
Array
The list of numeric vectors of selected variable.
coolingRate
Number
The number of iterations of simulated annealing. Defaults to 1
saMaxIt
Number
The number of iterations of simulated annealing. Defaults to 1
inits
Number
The number of construction re-runs, which is for ARiSeL "automatic regionalization with initial seed location"
initRegion
Array
The initial regions that the local search starts with. Default is empty. means the local search starts with a random process to "grow" clusters
minBoundValues
Array
The list of numeric array of selected minimum bounding variables.
minBounds
Array
The list of minimum value that the sum value of bounding variables in each cluster should be greater than.
maxBoundValues
Array
The list of numeric array of selected maximum bounding variables.
maxBounds
Array
The list of minimum value that the sum value of bounding variables in each cluster should be less than.
scaleMethod
String
The scaling methods {'raw', 'standardize', 'demean', 'mad', 'range_standardize', 'range_adjust'}. Defaults to 'standardize'.
distanceMethod
String
The distance methods {"euclidean", "manhattan"}. Defaults to 'euclidean'.
seed
Number
The seed for random number generator.
Source:
Returns:
Return a ClusteringResult object: {'total_ss', 'within_ss', 'between_ss', 'ratio', 'clusters'}TypeObject
azpTabu(weights, k, values, tabuLength, convTabu, inits, initRegion, minBoundValues, minBounds, maxBoundValues, maxBounds, scaleMethod, distanceMethod, seed) → {Object}
A tabu-search algorithm to solve the AZP problem.
A tabu-search algorithm to solve the AZP problem.
Parameters:
Name
Type
Description
weights
WeightsResult
The weights object WeightsResult
k
Number
The number of spatially constrained clusters
values
Array
The list of numeric vectors of selected variable.
tabuLength
Number
The length of a tabu search heuristic of tabu algorithm. Defaults to 10.
convTabu
Number
The number of non-improving moves. Defaults to 10.
inits
Number
The number of construction re-runs, which is for ARiSeL "automatic regionalization with initial seed location"
initRegion
Array
The initial regions that the local search starts with. Default is empty. means the local search starts with a random process to "grow" clusters
minBoundValues
Array
The list of numeric array of selected minimum bounding variables.
minBounds
Array
The list of minimum value that the sum value of bounding variables in each cluster should be greater than.
maxBoundValues
Array
The list of numeric array of selected maximum bounding variables.
maxBounds
Array
The list of minimum value that the sum value of bounding variables in each cluster should be less than.
scaleMethod
String
The scaling methods {'raw', 'standardize', 'demean', 'mad', 'range_standardize', 'range_adjust'}. Defaults to 'standardize'.
distanceMethod
String
The distance methods {"euclidean", "manhattan"}. Defaults to 'euclidean'.
seed
Number
The seed for random number generator.
Source:
Returns:
Return a ClusteringResult object: {'total_ss', 'within_ss', 'between_ss', 'ratio', 'clusters'}TypeObject
callLisa(weights, values, permutations, seed) → {Object}
Helper function: apply LISA statistics.
Helper function: apply LISA statistics
Parameters:
Name
Type
Description
weights
String
The weights object WeightsResult
values
Array
The values that local moran statistics will be applied on.
permutations
Number
The number of permutations for the LISA computation. Default: 999.
  • @param {String} permutationMethod The permutation method used for the LISA computation. Options are 'complete', 'lookup'. Default: 'lookup'.
seed
Number
The seed for random number generator used in LISA statistics. Default: 123456789.
Source:
Returns:
An instance of LisaResultTypeObject
cartogram(mapUid, values) → {Array}
Create cartogram using the values in the map.
Create cartogram using the values in the map. In cartograms, the size of a variable's value corresponds to the size of a shape. The location of the circles is aligned as closely as possible to the location of the associated area through a nonlinear optimization routine
Parameters:
Name
Type
Description
mapUid
String
A unique map Id
values
Array
The values that the classify algorithm will be applied on.
Source:
Returns:
Returns an array of circles, which is defined as: { "properties": { "id" : 1}, "position": [0.01, 0.01], "radius": 0.1 }TypeArray
checkDistanceMethod(distanceMethod) → {Boolean}
Helper function: check if distance method is valid.
Helper function: check if distance method is valid.
Parameters:
Name
Type
Description
distanceMethod
String
Source:
Returns:
TypeBoolean
checkInputKernel(kernel) → {Boolean}
check if input kernel is valid.
check if input kernel is valid
Parameters:
Name
Type
Description
kernel
*
Source:
Returns:
TypeBoolean
checkMapUid(mapUid) → {Boolean}
Check if map uid is valid.
Check if map uid is valid
Parameters:
Name
Type
Description
mapUid
String
Source:
Returns:
TypeBoolean
checkScaleMethod(scaleMethod) → {Boolean}
Helper function: check if scale method is valid.
Helper function: check if scale method is valid.
Parameters:
Name
Type
Description
scaleMethod
String
Source:
Returns:
TypeBoolean
customBreaks(breakName, values, k) → {Object}
Custom breaks that wraps {'natural_breaks', 'quantile_breaks', 'stdDevBreaks', 'hinge15Breaks', 'hinge30Breaks'}.
Custom breaks that wraps {'natural_breaks', 'quantile_breaks', 'stdDevBreaks', 'hinge15Breaks', 'hinge30Breaks'}
Parameters:
Name
Type
Description
breakName
String
The break name: {'natural_breaks', 'quantile_breaks', 'stdDevBreaks', 'hinge15Breaks', 'hinge30Breaks'}
values
*
The values of selected variable.
k
*
The number of breaks.
Source:
Returns:
{'k','bins','breaks','id_array'}TypeObject
distanceMethods() → {Object}
Help function: Get distance methods.
Help function: Get distance methods.Source:
Returns:
TypeObject
ebRisk(eventValues, baseValues) → {Array}
Empirical Bayes (EB) Smoothed Rate.
Empirical Bayes (EB) Smoothed Rate
Parameters:
Name
Type
Description
eventValues
Array
The values of an event variable.
baseValues
Array
The values of an base variable.
Source:
Returns:
TypeArray
excessRisk(eventValues, baseValues) → {Array}
Excess Risk.
Excess Risk
Parameters:
Name
Type
Description
eventValues
Array
The values of an event variable.
baseValues
Array
The values of an base variable.
Source:
Returns:
TypeArray
free()
Free the memory used by wasm.
Free the memory used by wasmSource:
generateUid() → {String}
Help function: create a unique id for a Geojson map.
Help function: create a unique id for a Geojson mapSource:
Returns:
TypeString
getBounds(mapUid) → {Array}
Get map bounds.
Get map bounds
Parameters:
Name
Type
Description
mapUid
String
A unique map id that has been read into GeoDaWasm.
Source:
Returns:
TypeArray
getCentroids(mapUid) → {Array}
Get the centroids of geojson map.
Get the centroids of geojson map. Same as GEOS.algorithm.Centroid: the centroid were computed as a weighted sum of the centroids of a decomposition of the area into (possibly overlapping) triangles. The algorithm has been extended to handle holes and multi-polygons
Parameters:
Name
Type
Description
mapUid
String
A unique map id
Source:
Returns:
Returns an array of [x,y] coordinates (not projected) of the centroids.TypeArray
Example
// In node.js
const fs = require('fs');
const jsgeoda = require('jsgeoda');
const geoda = await jsgeoda.New();
let ab = fs.readFileSync("NAT.geojson").buffer;
let nat = geoda.readGeoJSON("NAT", ab);
let cent = geoda.getCentroids(nat);
getClusteringResult(r) → {Object}
Helper function: get clustering results.
Helper function: get clustering results
Parameters:
Name
Type
Description
r
Object
Source:
Returns:
{'clusters', 'total_ss', 'between_ss', 'within_ss', 'ratio'}TypeObject
getClusters() → {Array}
cluster indicators.
cluster indicatorsSource:
Returns:
TypeArray
getColumn(mapUid, colName) → {Array}
Get the values (numeric|string) of a column or field.
Get the values (numeric|string) of a column or field.
Parameters:
Name
Type
Description
mapUid
String
A unique map id.
colName
String
A string of column or field name.
Source:
Returns:
Returns the values of a column of field.TypeArray
getColumnNames(mapUid) → {Array}
Get the column names of the geojson map.
Get the column names of the geojson map
Parameters:
Name
Type
Description
mapUid
String
A unique map id.
Source:
Returns:
Returns the column namesTypeArray
getColors() → {Array}
Get colors.
Get colorsSource:
Returns:
TypeArray
getConnectivity(weights) → {Object}
Get connectivity graph from a weights object.
Get connectivity graph from a weights object
Parameters:
Name
Type
Description
weights
String
The weights object WeightsResult
Source:
Returns:
{arcs, targets, sources}TypeObject
getDistanceWeights(mapUid, distThreshold, power, isInverse, isArc, isMile) → {Object}
Create a Distance-based weights.
Create a Distance-based weights.
Parameters:
Name
Type
Description
mapUid
String
A unique map id.
distThreshold
Number
A positive numeric value of distance threshold used to find neighbors.
power
Number
The power (or exponent) indicates how many times to use the number in a multiplication.
isInverse
Boolean
A bool flag indicates whether or not to apply inverse on distance value.
isArc
Boolean
A bool flag indicates if compute arc distance (true) or Euclidean distance (false).
isMile
Boolean
A bool flag indicates if the distance unit is mile (true) or km (false).
Source:
Returns:
An instance of GeoDaWeightsTypeObject
getKernelKnnWeights(mapUid, k, kernel, adaptiveBandwidth, useKernelDiagonals, power, isInverse, isArc, isMile) → {Object}
Create a (adaptive) KNN kernel weights.
Create a (adaptive) KNN kernel weights.
Parameters:
Name
Type
Description
mapUid
String
A unique map id.
k
Number
A positive integer number for k-nearest neighbors
kernel
String
The name of the kernel function, which could be one of the following: {triangular, uniform, quadratic, epanechnikov, quartic, gaussian}
adaptiveBandwidth
Boolean
A bool flag indicates whether to use adaptive bandwidth or the max distance of all observation to their k-nearest neighbors.
useKernelDiagonals
Boolean
A bool flag indicates whether or not the lower order neighbors should be included in the weights structure.
power
Number
The power (or exponent) indicates how many times to use the number in a multiplication.
isInverse
Boolean
A bool flag indicates whether or not to apply inverse on distance value.
isArc
Boolean
A bool flag indicates if compute arc distance (true) or Euclidean distance (false).
isMile
Boolean
A bool flag indicates if the distance unit is mile (true) or km (false)
Source:
Returns:
An instance of GeoDaWeightsTypeObject
getKernelWeights(mapUid, bandwidth, kernel, adaptive_bandwidth, useKernelDiagonals, power, isInverse, isArc, isMile) → {Object}
Create a kernel weights with fixed bandwidth.
Create a kernel weights with fixed bandwidth.
Parameters:
Name
Type
Description
mapUid
String
A unique map id.
bandwidth
Number
The bandwidth (distance threshold).
kernel
String
The name of the kernel function, which could be one of the following: {triangular, uniform, quadratic, epanechnikov, quartic, gaussian}
adaptive_bandwidth
Boolean
A bool flag indicates whether to use adaptive bandwidth or the max distance of all observation to their k-nearest neighbors.
useKernelDiagonals
Boolean
A bool flag indicates whether or not the lower order neighbors should be included in the weights structure.
power
Number
The power (or exponent) indicates how many times to use the number in a multiplication.
isInverse
Boolean
A bool flag indicates whether or not to apply inverse on distance value.
isArc
Boolean
A bool flag indicates if compute arc distance (true) or Euclidean distance (false).
isMile
Boolean
A bool flag indicates if the distance unit is mile (true) or km (false).
Source:
Returns:
An instance of GeoDaWeightsTypeObject
getKnnWeights(mapUid, k, power, isInverse, isArc, isMile) → {Object}
Create a K-Nearest Neighbors weights.
Create a K-Nearest Neighbors weights.
Parameters:
Name
Type
Description
mapUid
String
A unique map id.
k
Number
A positive integer number for k-nearest neighbors
power
Number
The power (or exponent) indicates how many times to use the number in a multiplication.
isInverse
Boolean
A bool flag indicates whether or not to apply inverse on distance value.
isArc
Boolean
A bool flag indicates if compute arc distance (true) or Euclidean distance (false).
isMile
Boolean
A bool flag indicates if the distance unit is mile (true) or km (false).
Source:
Returns:
An instance of GeoDaWeightsTypeObject
getLabels() → {Array}
Get labels.
Get labelsSource:
Returns:
TypeArray
getLisaValues() → {Array}
lisa values.
lisa valuesSource:
Returns:
TypeArray
getMapType(mapUid) → {Number}
Get map type.
Get map type
Parameters:
Name
Type
Description
mapUid
String
A unique map id
Source:
Returns:
return map typeTypeNumber
getMinDistancethreshold(mapUid, isArc, isMile) → {Number}
Get a distance that guarantees that every observation has at least 1 neighbor.
Get a distance that guarantees that every observation has at least 1 neighbor.
Parameters:
Name
Type
Description
mapUid
String
A unique map id.
isArc
Boolean
A bool flag indicates if compute arc distance (true) or Euclidean distance (false).
isMile
Boolean
A bool flag indicates if the distance unit is mile (true) or km (false).
Source:
Returns:
TypeNumber
getNeighbors(weights, idx) → {Array}
Get neighbors (indices) of an observation.
Get neighbors (indices) of an observation.
Parameters:
Name
Type
Description
weights
String
The weights object WeightsResult
idx
Number
An integer number represents the index of which observation to get its neighbors.
Source:
Returns:
The indices of neighbors.TypeArray
getNeighbors() → {Array}
nearest neighbors.
nearest neighborsSource:
Returns:
TypeArray
getNumObs(mapUid) → {Number}
Get the number of observations or rows in the geojson map.
Get the number of observations or rows in the geojson map.
Parameters:
Name
Type
Description
mapUid
String
A unique map id
Source:
Returns:
Returns the number of observations or rows in the geojson map.TypeNumber
getPValues() → {Array}
psudo-p values.
psudo-p valuesSource:
Returns: