pygmi.raster.iodefs#
Import and export routines for raster data.
Classes#
A combobox to select data bands. |
|
Import Data GUI - Interfaces with rasterio routines. |
|
Import RGB Image GUI- Interfaces with rasterio routines. |
|
Export Data GUI. |
Functions#
|
Prepare Cluster data from raster data. |
|
Import ascii raster dataset. |
|
Get raster dataset. |
|
Get BIL format file. |
|
Geopak Import. |
|
Get Geosoft file. |
|
Export to rasterio format. |
|
Calculate covariance from PyGMI Data. |
Module Contents#
- class pygmi.raster.iodefs.BandSelect(parent=None)#
Bases:
pygmi.misc.ContextModule
A combobox to select data bands.
- Parameters:
parent (parent, optional) – Reference to the parent routine. The default is None.
- run()#
Entry point into the routine, used to run context menu item.
- Returns:
True if successful, False otherwise.
- Return type:
bool
- class pygmi.raster.iodefs.ImportData(parent=None, ifile='', filt='')#
Bases:
pygmi.misc.BasicModule
Import Data GUI - Interfaces with rasterio routines.
- Parameters:
parent (parent, optional) – Reference to the parent routine. The default is None.
ifile (str, optional) – Input file. The default is ‘’.
filt (str, optional) – File filter. The default is ‘’.
- settings(nodialog=False)#
Entry point into item.
- Parameters:
nodialog (bool, optional) – Run settings without a dialog. The default is False.
- Returns:
True if successful, False otherwise.
- Return type:
bool
- saveproj()#
Save project data from class.
- Return type:
None
- class pygmi.raster.iodefs.ImportRGBData(parent=None)#
Bases:
pygmi.misc.BasicModule
Import RGB Image GUI- Interfaces with rasterio routines.
- Parameters:
parent (parent, optional) – Reference to the parent routine. The default is None.
- settings(nodialog=False)#
Entry point into item.
- Parameters:
nodialog (bool, optional) – Run settings without a dialog. The default is False.
- Returns:
True if successful, False otherwise.
- Return type:
bool
- saveproj()#
Save project data from class.
- Return type:
None.
- pygmi.raster.iodefs.clusterprep(dat)#
Prepare Cluster data from raster data.
- Parameters:
dat (list of pygmi.raster.datatypes.Data) – List of PyGMI datasets.
- Returns:
dat2 – List of PyGMI datasets.
- Return type:
list of pygmi.raster.datatypes.Data
- pygmi.raster.iodefs.get_ascii(ifile)#
Import ascii raster dataset.
- Parameters:
ifile (str) – filename to import
- Returns:
dat – dataset imported
- Return type:
PyGMI raster Data
- pygmi.raster.iodefs.get_raster(ifile, *, nval=None, piter=None, showlog=print, iraster=None, driver=None, bounds=None, tnames=None, metaonly=False, out_shape=None)#
Get raster dataset.
This function loads a raster dataset off the disk using the rasterio libraries. It returns the data in a PyGMI data object.
- Parameters:
ifile (str) – filename to import
nval (float, optional) – Nodata/null value. The default is None.
piter (function, optional) – progress bar iterable, default is None.
showlog (function, optional) – Routine to show text messages. The default is print.
iraster (None or tuple) – Incremental raster import, to import a section of a file. The tuple is (xoff, yoff, xsize, ysize). The default is None.
driver (str) – GDAL raster driver name. The default is None.
bounds (tuple) – Bounds of data to import as (left, bottom, right, top)
tnames (list, optional) – list of band names to import, in order. The default is None.
metaonly (bool, optional) – Retrieve only the metadata for the file. The default is False.
out_shape (tuple, optional) – Tuple describing the output array’s shape.
- Returns:
dat – Raster dataset imported
- Return type:
list of pygmi.raster.datatypes.Data
- pygmi.raster.iodefs.get_bil(ifile, bands, cols, rows, dtype, *, piter=iter, iraster=None, interleave='LINE')#
Get BIL format file.
This routine is called from get_raster
- Parameters:
ifile (str) – filename to import
bands (int) – Number of bands.
cols (int) – Number of columns.
rows (int) – Number of rows.
dtype (data type) – Data type.
piter (function) – progress bar iterable.
iraster (None or tuple) – Incremental raster import, to import a section of a file. The tuple is (xoff, yoff, xsize, ysize). The default is None.
interleave (str) – Band interleave. Default is ‘LINE’
- Returns:
datin – dataset imported
- Return type:
PyGMI raster Data
- pygmi.raster.iodefs.get_geopak(hfile)#
Geopak Import.
- Parameters:
hfile (str) – filename to import
- Returns:
dat – PyGMI raster dataset.
- Return type:
list of pygmi.raster.datatypes.Data
- pygmi.raster.iodefs.get_geosoft(hfile)#
Get Geosoft file.
- Parameters:
ifile (str) – filename to import
- Returns:
dat – Dataset imported
- Return type:
list of pygmi.raster.datatypes.Data
- class pygmi.raster.iodefs.ExportData(parent=None)#
Bases:
pygmi.misc.ContextModule
Export Data GUI.
- Parameters:
parent (parent, optional) – Reference to the parent routine. The default is None.
- ofile#
output file name.
- Type:
str
- setupui()#
Set up UI.
- Return type:
None.
- run()#
Entry point into the routine, used to run context menu item.
- Returns:
True if successful, False otherwise.
- Return type:
bool
- acceptall()#
Accept choice.
- export_gxf(data)#
Export GXF data.
- Parameters:
data (PyGMI raster Data) – dataset to export
- Return type:
None.
- export_surfer(data)#
Routine to export a surfer binary grid.
- Parameters:
data (PyGMI raster Data) – dataset to export
- Return type:
None.
- export_ascii(data)#
Export ASCII file.
- Parameters:
data (PyGMI raster Data) – dataset to export
- Return type:
None.
- export_ascii_xyz(data)#
Export and xyz file.
- Parameters:
data (PyGMI raster Data) – dataset to export
- Return type:
None.
- get_filename(data, ext)#
Get a valid filename in the case of multi band image.
- Parameters:
data (PyGMI raster Data) – dataset to get filename from
ext (str) – filename extension to use
- Returns:
file_out – Output filename.
- Return type:
str
- get_ofile()#
Get output directory.
- pygmi.raster.iodefs.export_raster(ofile, dat, *, drv='GTiff', piter=None, compression='NONE', bandsort=True, showlog=print, updatestats=True)#
Export to rasterio format.
- Parameters:
ofile (str) – Output file name.
dat (list or dictionary of PyGMI raster Data) – dataset to export
drv (str) – name of the rasterio driver to use
piter (function, optional) – Progressbar iterable. The default is None.
compression (str, optional) – Compression for GeoTIFF. Can be NONE, DEFLATE or ZSTD. The default is NONE.
bandsort (bool, optional) – sort the bands by dataid. The default is True
showlog (function, optional) – Show information using a function. The default is print.
updatestats (bool, optional) – Update statistics in exported file.
- Return type:
None.
- pygmi.raster.iodefs.calccov(data, showlog=print)#
Calculate covariance from PyGMI Data.
This routine assumes all bands are co-located, with the same size. Otherwise, run lstack first.
- Parameters:
data (list of pygmi.raster.datatypes.Data) – List of PyGMI data.
showlog (function, optional) – Show information using a function. The default is print.
- Returns:
dcov – Covariances.
- Return type:
numpy array