grat.loaders.get_sites
¶
Constructs site classes from the attributes of a sites layer (shapefile, geodatabase, geopackage or csv).
read_attributes
¶
Reads the attribute table of a sites layer into a dataframe. Geometry is not read.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
csv, or any vector file GDAL can read (shapefile, file geodatabase folder, geopackage, geojson) |
required | |
layer
|
layer name, for files that hold more than one (e.g. a feature class in a file geodatabase) |
None
|
|
where
|
optional sql where clause, e.g. |
None
|
Returns:
| Type | Description |
|---|---|
|
dataframe with one row per site |
Source code in src/grat/loaders/get_sites.py
load_sites
¶
Loads the crop/basin sites layer.
Each row is turned into a dictionary with the keys being the attribute field names (or the attribute_renamer argument) and the values are the row values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
csv, or any vector file GDAL can read (shapefile, file geodatabase folder, geopackage, geojson) |
required | |
layer
|
layer name, for files that hold more than one (e.g. a feature class in a file geodatabase) |
None
|
|
where
|
optional sql where clause, e.g. |
None
|
|
ignore_fields
|
list of fields to ignore |
None
|
|
attribute_renamer
|
dictionary of attributes to rename to something different |
None
|
Returns:
| Type | Description |
|---|---|
|
list of dictionaries |
Source code in src/grat/loaders/get_sites.py
parse_compatible_sources
¶
Split WAFRSOURCE string (comma-delimited) into a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
compatible_sources
|
string |
required |
Returns:
| Type | Description |
|---|---|
|
list of WAFR source names |
Source code in src/grat/loaders/get_sites.py
parse_bottleneck_ids
¶
Split string (comma-delimited) into a list of integers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bottleneck_id_string
|
string, or a number when the field holds a single id |
required |
Returns:
| Type | Description |
|---|---|
|
list of bottleneck ids, or None when the string is empty |
Source code in src/grat/loaders/get_sites.py
build_sites
¶
Takes a list of input dictionaries and creates the OFR + Basin + other object types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sites_dictionary_list
|
list of site attribute dictionaries, keyed by |
required |
Returns:
| Type | Description |
|---|---|
|
list of site objects |
Source code in src/grat/loaders/get_sites.py
drop_invalid_sites
¶
Drops sites if the crops types don't match the values in the crop compatibility calendar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sites
|
list of sites object |
required | |
valid_crop_list
|
list of crop types from the crop compatibility calendar |
required | |
valid_il_crop_list
|
list of in-lieu crop types from the IL compatibility calendar |
required | |
valid_soil_types
|
list of soil classification types (also from the crop compatibility calendar) |
required |
Returns:
| Type | Description |
|---|---|
|
list of the sites that passed validation |