@icgcat/thematic-stats v0.0.8-c
@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-statsUsage
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.
| Param | Type | Description |
|---|---|---|
| fieldName | String | The field name used for matching values. |
| arrayData | Array | An array of data values. |
| arrayKeys | Array | An array of keys corresponding to the data values. |
| geostatObj | Object | The GeoStats object containing data and color mapping. |
| forceInt | Boolean | Whether 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.
| Param | Type | Description |
|---|---|---|
| fieldName | String | The field name used for styling. |
| arrayValues | Array | An array of numeric values defining range boundaries. |
| arrayColors | Array | An 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.