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:

TypeArray

getQueenWeights(mapUid, order, includeLowerOrder, precision_threshold) → {Object}

Create a contiguity weights.

Create a contiguity weights.

Parameters:

Name

Type

Description

mapUid

String

A unique map id.

order

Number

An integet number for order of contiguity

includeLowerOrder

Boolean

Indicate if include lower order when creating weights

precision_threshold

Number

Used when the precision of the underlying shape file is insufficient to allow for an exact match of coordinates to determine which polygons are neighbors.

Source:

Returns:

An instance of GeoDaWeightsTypeObject

getRookWeights(mapUid, order, includeLowerOrder, precisionThreshold) → {Object}

Create a Rook contiguity weights.

Create a Rook contiguity weights.

Parameters:

Name

Type

Description

mapUid

String

A unique map id.

order

Number

An integet number for order of contiguity

includeLowerOrder

Boolean

Indicate if include lower order when creating weights

precisionThreshold

Number

Used when the precision of the underlying shape file is insufficient to allow for an exact match of coordinates to determine which polygons are neighbors.

Source:

Returns:

An instance of GeoDaWeightsTypeObject

getViewport(mapUid, mapHeight, mapWidth) → {Object}

Get viewport for e.g.

Get viewport for e.g. Deck.gl or GoogleMaps

Parameters:

Name

Type

Description

mapUid

String

A unique map id

mapHeight

Number

The height of map (screen pixel)

mapWidth

Number

The width of map (screen pixel)

Source:

Returns:

TypeObject

has(mapUid) → {Boolean}

Check if a geojson map has been read into GeoDaWasm.

Check if a geojson map has been read into GeoDaWasm.

Parameters:

Name

Type

Description

mapUid

String

A unique map id that has been read into GeoDaWasm.

Source:

Returns:

Returns True if the geojson map has been read. Otherwise, returns False.TypeBoolean

hinge15Breaks(values) → {Array}

Boxplot (hinge=1.5) breaks, including the top, bottom, median, and two quartiles of the data.

Boxplot (hinge=1.5) breaks, including the top, bottom, median, and two quartiles of the data

Parameters:

Name

Type

Description

values

Array

The values of selected variable.

Source:

Returns:

Returns an array of break point values.TypeArray

hinge30Breaks(values) → {Array}

Boxplot (hinge=3.0) breaks, including the top, bottom, median, and two quartiles of the data.

Boxplot (hinge=3.0) breaks, including the top, bottom, median, and two quartiles of the data

Parameters:

Name

Type

Description

values

Array

The values of selected variable.

Source:

Returns:

Returns an array of break point values.TypeArray

isInt(n) → {Boolean}

Help function: check if number is an integer.

Help function: check if number is an integer.

Parameters:

Name

Type

Description

n

Number

Source:

Returns:

TypeBoolean

localBiJoinCount(weights, values1, values2, permutations, significanceCutoff, seed) → {Object}

Bivariate or no-colocation local join count works when two events cannot happen in the same location.

Bivariate or no-colocation local join count works when two events cannot happen in the same location. It can be used to identify negative spatial autocorrelation.

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

values1

Array

The first numeric column that contains the binary values (e.g. 0 and 1) for LISA statistics

values2

Array

The second numeric column that contains the binary values (e.g. 0 and 1) for LISA statistics

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'.

significanceCutoff

Number

The cutoff value for significance p-values to filter not-significant clusters. Default: 0.05

seed

Number

The seed for random number generator

Source:

Returns:

LISA object GeoDaLisaTypeObject

localG(weights, values, permutations, seed) → {Object}

Apply local G statistics.

Apply local G 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

localGeary(weights, values, permutations, permutationMethod, seed) → {Object}

Apply local Geary statistics.

Apply local Geary 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.

permutationMethod

String

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

localGStar(weights, values, permutations, seed) → {Object}

Apply local G* statistics.

Apply local G* 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

localJoinCount(weights, values, permutations, seed) → {Object}

Apply local Join Count statistics.

Apply local Join Count 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

localMoran(weights, values, permutations, seed) → {Object}

Apply local Moran statistics.

Apply local Moran 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

localMultiGeary(weights, values1, permutations, significanceCutoff, seed) → {Object}

Multivariate local geary is a multivariate extension of local geary which measures the extent to which neighbors in multiattribute space are also neighbors in geographical space.

Multivariate local geary is a multivariate extension of local geary which measures the extent to which neighbors in multiattribute space are also neighbors in geographical space.

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

values1

Array

The array of the numeric columns that contains the values for LISA statistics

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'.

significanceCutoff

Number

The cutoff value for significance p-values to filter not-significant clusters. Default: 0.05

seed

Number

The seed for random number generator

Source:

Returns:

LISA object GeoDaLisaTypeObject

localMultiJoinCount(weights, values, permutations, significanceCutoff, seed) → {Object}

Multivariate or colocation local join count (2019) works when two or more events happen in the same location.

Multivariate or colocation local join count (2019) works when two or more events happen in the same location.

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

values

Array

The array of numeric columns that contains the binary values (e.g. 0 and 1) for LISA statistics

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'.

significanceCutoff

Number

The cutoff value for significance p-values to filter not-significant clusters. Default: 0.05

seed

Number

The seed for random number generator

Source:

Returns:

LISA object GeoDaLisaTypeObject

maxpGreedy(weights, values, iterations, minBoundValues, minBounds, maxBoundValues, maxBounds, scaleMethod, distanceMethod, seed) → {Object}

A greedy algorithm to solve the max-p-region problem.

A greedy algorithm to solve the max-p-region problem.

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

values

Array

The list of numeric vectors of selected variable.

iterations

Number

The number of iterations of greedy algorithm. Defaults to 1.

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

maxpSA(weights, values, coolingRate, saMaxIt, iterations, minBoundValues, minBounds, maxBoundValues, maxBounds, scaleMethod, distanceMethod, seed) → {Object}

A simulated annealing algorithm to solve the max-p-region problem.

A simulated annealing algorithm to solve the max-p-region problem.

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

values

Array

The list of numeric vectors of selected variable.

coolingRate

Number

The cooling rate of a simulated annealing algorithm. Defaults to 0.85

saMaxIt

Number

The number of iterations of simulated annealing. Defaults to 1

iterations

Number

The number of iterations of greedy algorithm. Defaults to 1.

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

maxpTabu(weights, values, tabuLength, convTabu, iterations, minBoundValues, minBounds, maxBoundValues, maxBounds, scaleMethod, distanceMethod, seed) → {Object}

A tabu-search algorithm to solve the max-p-region problem.

A tabu-search algorithm to solve the max-p-region problem

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

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.

iterations

Number

The number of iterations of greedy algorithm. Defaults to 1.

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

multiQuantileLisa(weights, ks, quantiles, values, permutations, significanceCutoff, seed) → {Object}

Multivariate Quantile LISA (2019) is a type of local spatial autocorrelation that applies multivariate local join count statistics to quantiles of multiple continuous variables.

Multivariate Quantile LISA (2019) is a type of local spatial autocorrelation that applies multivariate local join count statistics to quantiles of multiple continuous variables.

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

ks

Array

The array of integer numbers that specify quantiles for each variable

quantiles

Array

The array of integer numbers that specify which quantile is used for each variable

values

Array

The array of numeric columns that contains the binary values (e.g. 0 and 1) for LISA statistics

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'.

significanceCutoff

Number

The cutoff value for significance p-values to filter not-significant clusters. Default: 0.05

seed

Number

The seed for random number generator

Source:

Returns:

LISA object GeoDaLisaTypeObject

naturalBreaks(k, values) → {Array}

Natural breaks.

Natural breaks

Parameters:

Name

Type

Description

k

Number

Number of breaks

values

Array

The values that the classify algorithm will be applied on.

Source:

Returns:

Returns an array of break point values.TypeArray

neighborMatchTest(mapUid, knn, data, scaleMethod, distanceMethod, power, isInverse, isArc, isMile) → {Array}

The local neighbor match test is a method to identify significant locations by assessing the extent of overlap between k-nearest neighbors in geographical space and k-nearest neighbors in multi-attribute space.

The local neighbor match test is a method to identify significant locations by assessing the extent of overlap between k-nearest neighbors in geographical space and k-nearest neighbors in multi-attribute space.

Parameters:

Name

Type

Description

mapUid

String

A unique string represents the geojson map that has been read into GeoDaWasm.

knn

Number

k nearest neighbor for both attribute and geographical space

data

Array

The array of numeric columns that contains the values for neighbor match test

scaleMethod

String

The scaling method: {'raw', 'standardize', 'demean', 'mad', 'range_standardize', 'range_adjust'}. Default: 'standardize'

distanceMethod

String

The distance method: {'euclidean', 'manhattan'}. Default: 'euclidean'.

power

Number

The power/exponent corresponds to the number of times the base (dist_band) is used as a factor. Default: 1.

isInverse

Boolean

The bool value indicates if apply inverse on distance value. Default: False.

isArc

Boolean

The bool value indicates if compute arc distance between two observations. Default: FALSE.

isMile

Boolean

The bool value indicates if convert distance unit from mile to kilometer(KM). Default: TRUE.

Source:

Returns:

{'cardinality', 'probability'}TypeArray

New() → {Object}

Create a GeoDaWasm instance built using WASM.

Create a GeoDaWasm instance built using WASM.Source:

Returns:

geoda - a GeoDaWasm instance built from WASMTypeObject

Example

const jsgeoda = require('jsgeoda')
let geoda = await jsgeoda.New()

parseVecDouble(input) → {Object}

Help function: convert GeoDa std::vector to javascript Array e.g.

Help function: convert GeoDa std::vector to javascript Array e.g. []

Parameters:

Name

Type

Description

input

Array

Source:

Returns:

TypeObject

parseVecInt(input) → {Object}

Help function: convert GeoDa std::vector to javascript Array e.g.

Help function: convert GeoDa std::vector to javascript Array e.g. []

Parameters:

Name

Type

Description

input

Array

Source:

Returns:

TypeObject

parseVecString(input) → {Object}

Help function: convert GeoDa std::vector to javascript Array e.g.

Help function: convert GeoDa std::vector to javascript Array e.g. []

Parameters:

Name

Type

Description

input

Array

Source:

Returns:

TypeObject

parseVecVecDouble(input) → {Object}

Help function: convert GeoDa 2d std::vector to javascript 2d Array e.g.

Help function: convert GeoDa 2d std::vector to javascript 2d Array e.g. [[]]

Parameters:

Name

Type

Description

input

Array

Source:

Returns:

TypeObject

parseVecVecInt(input) → {Object}

Help function: convert GeoDa 2d std::vector to javascript 2d Array e.g.

Help function: convert GeoDa 2d std::vector to javascript 2d Array e.g. [[]]

Parameters:

Name

Type

Description

input

Array

Source:

Returns:

TypeObject

percentileBreaks(values) → {Array}

Percentile breaks.

Percentile breaks

Parameters:

Name

Type

Description

values

Array

The values of selected variable.

Source:

Returns:

Returns an array of break point values.TypeArray

quantileBreaks(k, values) → {Array}

Quantile breaks.

Quantile breaks

Parameters:

Name

Type

Description

k

Number

The number of breaks

values

Array

The values of selected variable.

Source:

Returns:

Returns an array of break point values.TypeArray

quantileLisa(weights, values, permutations, seed) → {Object}

Apply Quantile LISA statistics.

Apply Quantile 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

readGeoJSON(ab) → {String}

Read a geojson map from a file object in the format of ArrayBuffer.

Read a geojson map from a file object in the format of ArrayBuffer. You can use readFileSync in fs to read the geojson file and return a ArrayBuffer; Or use FileReader.readAsArrayBuffer to read the content of a specified Blob of File.

Parameters:

Name

Type

Description

ab

ArrayBuffer

The content of the geojson file in format of ArrayBuffer.

Source:

Returns:

A unique id of the geoda object.TypeString

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(ab);
let numObs = geoda.getNumObs(nat);

E.g. the geojson file name.

redcap(weights, k, values, method, minBound, boundVals, scaleMethod, distanceMethod) → {Object}

Regionalization with dynamically constrained agglomerative clustering and partitioning (REDCAP).

Regionalization with dynamically constrained agglomerative clustering and partitioning (REDCAP)

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

k

Number

The number of clusters

values

Array

The list of numeric vectors of selected variable

method

String

The REDCAP method: {'single-linkage', 'average-linkage', 'complete-linkage', 'Ward-linkage'}.

minBound

Number

The minimum value that the sum value of bounding variable in each cluster should be greater than

boundVals

Array

The numeric vector of selected bounding variable

scaleMethod

String

The scaling method: {'raw', 'standardize', 'demean', 'mad', 'range_standardize', 'range_adjust'}

distanceMethod

String

The distance method: {"euclidean", "manhattan"}

Source:

Returns:

Return a ClusteringResult object: {'total_ss', 'within_ss', 'between_ss', 'ratio', 'clusters'}TypeObject

redcapMethods() → {Array}

Helper function: Get REDCAP methods.

Helper function: Get REDCAP methods.Source:

Returns:

TypeArray

scaleMethods() → {Object}

Help function: Get scale methods.

Help function: Get scale methods.Source:

Returns:

TypeObject

schc(weights, k, values, method, minBound, boundVals, scaleMethod, distanceMethod) → {Object}

Spatially Constrained Hierarchical Clucstering (SCHC).

Spatially Constrained Hierarchical Clucstering (SCHC)

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

k

Number

The number of clusters

values

Array

The list of numeric vectors of selected variable

method

String

The method of agglomerative hierarchical clustering: {"single", "complete", "average","ward"}.

minBound

Number

The minimum value that the sum value of bounding variable in each cluster should be greater than

boundVals

Array

The numeric vector of selected bounding variable

scaleMethod

String

The scaling method: {'raw', 'standardize', 'demean', 'mad', 'range_standardize', 'range_adjust'}

distanceMethod

String

The distance method: {"euclidean", "manhattan"}

Source:

Returns:

Return a ClusteringResult object: {'total_ss', 'within_ss', 'between_ss', 'ratio', 'clusters'}TypeObject

schcMethods() → {Array}

Get the SCHC methods.

Get the SCHC methods.Source:

Returns:

TypeArray

skater(weights, k, values, minBound, boundVals, scaleMethod, distanceMethod) → {Object}

Spatial C(K)luster Analysis by Tree Edge Removal.

Spatial C(K)luster Analysis by Tree Edge Removal

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

k

Number

The number of clusters

values

Array

The list of numeric vectors of selected variable

minBound

Number

The minimum value that the sum value of bounding variable int each cluster should be greater than

boundVals

Array

The numeric vector of selected bounding variable

scaleMethod

String

The scaling method: {'raw', 'standardize', 'demean', 'mad', 'range_standardize', 'range_adjust'}

distanceMethod

String

The distance method: {"euclidean", "manhattan"}

Source:

Returns:

Return a ClusteringResult object: {'total_ss', 'within_ss', 'between_ss', 'ratio', 'clusters'TypeObject

spatialEB(weights, eventValues, baseValues) → {Array}

Spatial Empirical Bayes (EB) Smoothing.

Spatial Empirical Bayes (EB) Smoothing

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

eventValues

Array

The values of an event variable.

baseValues

Array

The values of an base variable.

Source:

Returns:

TypeArray

spatialLag(weights, values, isBinary, rowStandardize, includeDiagonal) → {Array}

Compute spatially lagged variable.

Compute spatially lagged variable.

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

values

Array

The values of a selected variable.

isBinary

Boolean

The bool value indicates if the spatial weights is used as binary weights. Default: TRUE.

rowStandardize

Boolean

The bool value indicates if use row-standardized weights. Default: TRUE

includeDiagonal

Bollean

The bool value indicates if include diagonal of spatial weights. Default: FALSE

Source:

Returns:

TypeArray

spatialRate(weights, eventValues, baseValues) → {Array}

Spatial rate smoothing.

Spatial rate smoothing

Parameters:

Name

Type

Description

weights

WeightsResult

The weights object WeightsResult

eventValues

Array

The values of an event variable.

baseValues

Array

The values of an base variable.

Source:

Returns:

TypeArray

standardDeviationBreaks(values) → {Array}

Standard deviation breaks.

Standard deviation breaks

Parameters:

Name

Type

Description

values

Array

The values of selected variable.

Source:

Returns:

Returns an array of break point values.TypeArray

toVecDouble(input) → {Object}

Help function: convert javascript Array e.g.

Help function: convert javascript Array e.g. [] to GeoDa std::vector

Parameters:

Name

Type

Description

input

Array

Source:

Returns:

TypeObject

toVecInt(input) → {Object}

Help function: convert javascript Array e.g.

Help function: convert javascript Array e.g. [] to GeoDa std::vector

Parameters:

Name

Type

Description

input

Array

Source:

Returns:

TypeObject

toVecString(input) → {Object}

Help function: convert javascript Array e.g.

Help function: convert javascript Array e.g. [] to GeoDa std::vector

Parameters:

Name

Type

Description

input

Array

Source:

Returns:

TypeObject

toVecVecDouble(input) → {Object}

Help function: convert javascript 2d Array e.g.

Help function: convert javascript 2d Array e.g. [[]] to GeoDa 2d std::vector

Parameters:

Name

Type

Description

input

Array

Source:

Returns:

TypeObject

Last updated