rast_converter¶
Conversion of rasters into tables. This module provides a command line tool and a function that both ingest a raster file and produce 3 column parquet table with coordinates and band value.
See the data_ingestion notebook for templates of this.
- scalenav.rast_converter.check_crs(source, in_crs)¶
Check that the source CRS is provided.
- Parameters:
source (DatasetReader) – Source raster file
in_crs (str) – Alternative CRS to use
- Returns:
Returns the source csrs if it is provided, or an alternative.
- Return type:
string
- scalenav.rast_converter.check_nodata(source)¶
Checking the nodata field in a raster, assume it’s 0 if not present
- Parameters:
source (DatasetReader) – A raster data source
- Returns:
Based on whether a nodata values can be read from the source, return this value or 0 if not
- Return type:
numeric
- scalenav.rast_converter.check_out_crs(val)¶
Check the requested out crs is valid
- Parameters:
val (str) – A string representing a CRS, for example ‘epsg:4326’
- Returns:
A CRS object
- Return type:
rasterio.CRS
- scalenav.rast_converter.check_path(in_path)¶
- What are we checking ?
UNDER DEV - input contains one of the desired file resolutions. - if folder file, extract all raster format files from it. - if specific file, then just use that. - some robustness to user input should be embedded here. For example when providing folder path: ‘/the/folder/with/rast/’ and /the/folder/with/rast’ as two potential accepted values. - also relative and absolute paths.
- Parameters:
in_path (str) – Path to a raster file or folder with rasters.
- Returns:
A string path or a list of paths depending whether the input is a file path or folder respectively
- Return type:
str
- scalenav.rast_converter.infer_dtype(source)¶
Simple function to avoid failures when data type is not recongnised, default assign float32()
- Parameters:
source (DatasetReader) – A raster data source
- Returns:
A type for the data schema specification, default is float32()
- Return type:
np.dtype
- scalenav.rast_converter.rast_convert_core(src, transform, win=None, band=1)¶
The core of the rast conversion can be put here in order to centralise the most efficient workflow that can be then used in the CL tool and function.
- Parameters:
src (DatasetReader) – Data read from a filestream
transform (a rasterio transform)
win (a rasterio window, optional) – default None
band (int, optional) – by default 1
- Returns:
A data frame of the transformed raster window.
- Return type:
DataFrame | pyarrow.table