0.0.8-c • Published 1 year ago

@icgcat/thematic-stats v0.0.8-c

Weekly downloads
-
License
BSD-3-Clause
Repository
-
Last release
1 year ago

License Version LinkedIn

@icgcat/thematic-stats

Introduction

@icgcat/thematic-stats is a Node.js package designed for statistical analysis, geospatial data processing, and thematic mapping. It provides utility functions for generating map styles, defining numeric data classifications, and visualizing data for mapping tools. This package is useful for developers, analysts, and GIS professionals handling geospatial datasets and creating thematic visualizations.


Installation

To install the package, use npm or yarn:

npm install @icgcat/thematic-stats

Usage

Import and Basic Example

Here's how to use the stats functions in your application:

<script>

import { generateStyleJSTAT, generateStyle } from '@icgcat/thematic-stats';

// Example 1: Generate a style for thematic mapping
const styleJSTAT = generateStyleJSTAT('population', [10, 20, 30], ['A', 'B', 'C'], false);
console.log(styleJSTAT);

// Example 2: Generate a step-based style
const style = generateStyle('density', [0, 100, 200, 300], ['#FFEDA0', '#FEB24C', '#F03B20']);
console.log(style);


let activeLayer = 'polygonLayerID'
map.setPaintProperty(activeLayer + "-pol", "fill-color", style); 

// or you can import stats from @icgc/stats and: 
// stats.setStyle(capaActiva, currentStyle)


</script>

Component Functions

generateStyleJSTAT(fieldName, arrayData, arrayKeys, geostatObj, forceInt) ⇒ Array

Generates a style configuration for thematic mapping based on GeoStats data.

Kind: global function
Returns: Array - A style configuration array for mapping tools.

ParamTypeDescription
fieldNameStringThe field name used for matching values.
arrayDataArrayAn array of data values.
arrayKeysArrayAn array of keys corresponding to the data values.
geostatObjObjectThe GeoStats object containing data and color mapping.
forceIntBooleanWhether to parse keys as integers.

Example

const style = generateStyleJSTAT('field', [10, 20], [1, 2], geoStatsObj, true);
console.log(style);

generateStyle(fieldName, arrayValues, arrayColors) ⇒ Array

Generates a step-based style configuration for mapping numeric ranges.

Kind: global function
Returns: Array - A style configuration array for mapping tools.

ParamTypeDescription
fieldNameStringThe field name used for styling.
arrayValuesArrayAn array of numeric values defining range boundaries.
arrayColorsArrayAn array of colors corresponding to each range.

Example

const style = generateStyle('field', [10, 20, 30], ['#FF0000', '#00FF00']);
console.log(style);

Developed by:

License

This project is licensed under the MIT License.

0.0.8-c

1 year ago

0.0.8-b

1 year ago

0.0.8-a

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago