Hazard
Helpers for location queries using CodedLocation from nzshm-common.
TODO: these coded-location string functions should move to nzshm-common.
downsample_code(loc_code, res)
¶
Get a CodedLocation.code at the chosen resolution from the given location code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loc_code
|
str
|
The location code in format 'latitude~longitude'. |
required |
resolution
|
int
|
Resolution in grid degrees to downsample to. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The downsampled location code. |
Examples:
>>> downsample_code('37.7749~-122.4194', 0.1)
'37.8~-122.4'
Source code in toshi_hazard_store/query/hazard_query.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
get_hashes(locs, resolution=0.1)
¶
Compute a set of hashes for the given locations at the specified resolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locs
|
Iterable[str]
|
A collection of location codes in the format 'latitude~longitude'. |
required |
resolution
|
float
|
The resolution to compute hashes at (in grid degrees). Defaults to 0.1. |
0.1
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
Iterable[str]
|
A sorted list of unique location codes, downsampled to the specified resolution. |
Source code in toshi_hazard_store/query/hazard_query.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |