Statistics Module¶
The statistics module provides functions to calculate and display statistics for various discrete global grid systems (DGGS), including cell counts, areas, and edge lengths.
Overview¶
The statistics module enables:
- Cell Count Analysis: Calculate the number of cells at each resolution
- Area Calculations: Determine average cell areas for each resolution
- Edge Length Analysis: Calculate average edge lengths for grid cells
Supported DGGS Systems¶
The statistics module supports comprehensive analysis of all major DGGS systems:
- H3: Uber's hexagonal hierarchical geospatial indexing system
- S2: Google's spherical geometry library
- A5: Pentagonal DGGS
- RHEALPix: Equal-area hierarchical triangular mesh
- ISEA4T: Icosahedral Snyder Equal Area Aperture 4 Triangle
- ISEA3H: Icosahedral Snyder Equal Area Aperture 3 Hexagon
- EASE: Equal-Area Scalable Earth Grid
- QTM: Quaternary Triangular Mesh
- OLC: Open Location Code (Plus Codes)
- Geohash: Hierarchical spatial data structure
- GEOREF: World Geographic Reference System
- MGRS: Military Grid Reference System
- Tilecode: Hierarchical tiling system
- Quadkey: Microsoft's hierarchical spatial index
- Maidenhead: Amateur radio grid square system
- GARS: Global Area Reference System
- DGGAL: External DGGS family accessed via the
dgg
CLI (e.g., GNOSIS, ISEA3H/9R, IVEA3H/9R, RTEA3H/9R, RHEALPix)
Key Metrics¶
Cell Counts¶
- Total number of cells at each resolution
- Hierarchical cell relationships
- Global coverage statistics
Area Analysis¶
- Average cell area in square meters
- Area consistency across resolutions
- Equal-area vs. non-equal-area systems
Edge Lengths¶
- Average edge length in meters
- Edge length consistency
- Geometric properties
Usage Examples¶
H3 Statistics¶
1 2 3 4 |
|
S2 Metrics¶
1 2 3 4 |
|
RHEALPix Statistics¶
1 2 3 4 |
|
DGGAL Statistics¶
1 2 3 4 5 6 |
|
Compare Multiple Systems¶
1 2 3 4 5 6 |
|
Output Formats¶
Statistics can be displayed in multiple formats:
- Terminal Tables: Dataframe for console display
- Metrics Arrays: Python arrays for programmatic use
Statistics module for vgrid.
This module provides functions to calculate and display statistics for various discrete global grid systems (DGGS), including cell counts, areas, and edge lengths.
a5_metrics(res, unit='m')
¶
Calculate metrics for A5 DGGS cells at a given resolution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (0-29) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, edge_length_in_unit, cell_area_in_unit_squared) |
Source code in vgrid/stats/a5stats.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
gars_metrics(res, unit='m')
¶
Calculate metrics for GARS DGGS cells.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (0-4) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, avg_edge_len_in_unit, avg_cell_area_in_unit_squared) |
Source code in vgrid/stats/garsstats.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
geohash_metrics(res, unit='m')
¶
Calculate metrics for Geohash DGGS cells.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (0-12) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, avg_edge_len_in_unit, avg_cell_area_in_unit_squared) |
Source code in vgrid/stats/geohashstats.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
georef_metrics(res, unit='m')
¶
Calculate metrics for GEOREF DGGS cells.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
int
|
Resolution level (0-7) |
required |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, avg_edge_len_in_unit, avg_cell_area_in_unit_squared) |
Source code in vgrid/stats/georefstats.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
isea3h_metrics(res, unit='m')
¶
Calculate metrics for ISEA3H DGGS cells at a given resolution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (0-40) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, edge_length_in_unit, cell_area_in_unit_squared) |
Source code in vgrid/stats/isea3hstats.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
isea4t_metrics(res, unit='m')
¶
Calculate metrics for ISEA4T DGGS cells at a given resolution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (0-39) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, edge_length_in_unit, cell_area_in_unit_squared) |
Source code in vgrid/stats/isea4tstats.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
maidenhead_metrics(res, unit='m')
¶
Calculate metrics for Maidenhead DGGS cells.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (0-4) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, avg_edge_len_in_unit, avg_cell_area_in_unit_squared) |
Source code in vgrid/stats/maidenheadstats.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
mgrs_metrics(res, unit='m')
¶
Calculate metrics for MGRS DGGS cells.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (0-5) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, avg_edge_len_in_unit, avg_cell_area_in_unit_squared) |
Source code in vgrid/stats/mgrsstats.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
olc_metrics(res, unit='m')
¶
Calculate metrics for OLC DGGS cells.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (0-15) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, avg_edge_len_in_unit, avg_cell_area_in_unit_squared) |
Source code in vgrid/stats/olcstats.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
qtm_metrics(res, unit='m')
¶
Calculate metrics for QTM DGGS cells.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (1-24) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, avg_edge_len_in_unit, avg_cell_area_in_unit_squared) |
Source code in vgrid/stats/qtmstats.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
quadkey_metrics(res, unit='m')
¶
Calculate metrics for Quadkey DGGS cells.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (0-30) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, avg_edge_len_in_unit, avg_cell_area_in_unit_squared) |
Source code in vgrid/stats/quadkeystats.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
rhealpix_metrics(res, unit='m')
¶
Calculate metrics for rHEALPix DGGS cells at a given resolution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (0-30) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, edge_length_in_unit, cell_area_in_unit_squared) |
Source code in vgrid/stats/rhealpixstats.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
s2_metrics(res, unit='m')
¶
Calculate metrics for S2 DGGS cells at a given resolution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (0-30) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, edge_length_in_unit, cell_area_in_unit_squared) |
Source code in vgrid/stats/s2stats.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
tilecode_metrics(res, unit='m')
¶
Calculate metrics for Tilecode DGGS cells.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res
|
Resolution level (0-30) |
required | |
unit
|
str
|
'm' or 'km' for length; area will be 'm^2' or 'km^2' |
'm'
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
(num_cells, avg_edge_len_in_unit, avg_cell_area_in_unit_squared) |
Source code in vgrid/stats/tilecodestats.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|