pygmi.rsense.iodefs#

Import remote sensing data.

Classes#

ImportData

Import Data GUI - Interfaces with rasterio routines.

ImportBatch

Batch Import Data Interface.

ImportSentinel5P

GUI import Sentinel 5P data and export to shapefile.

ExportBatch

GUI to export Raster File List.

Functions#

calculate_toa(dat[, showlog])

Top of atmosphere correction.

consolidate_aster_list(flist)

Consolidate ASTER files from a file list, getting rid of extra files.

convert_ll_to_utm(lon, lat)

Convert latitude and longitude to UTM.

etree_to_dict(t)

Convert an ElementTree to dictionary.

export_batch(indata, odir, filt, *[, tnames, piter, ...])

Export a batch of files directly from satellite format to disk.

files_to_rastermeta(allfiles[, piter, showlog])

Import files to a RasterMeta item.

get_data(ifile, *[, piter, showlog, tnames, metaonly, ...])

Load a raster dataset off the disk using the rasterio libraries.

get_from_rastermeta(ldata, *[, piter, showlog, ...])

Import data from a RasterMeta item.

get_emit(ifile[, piter, showlog, tnames, metaonly])

Get EMIT Data.

get_modisv6(ifile[, piter, showlog, tnames, metaonly])

Get MODIS v006 data.

get_landsat(ifilet[, piter, showlog, tnames, metaonly])

Get Landsat Data.

get_worldview(ifilet[, piter, showlog, tnames, metaonly])

Get WorldView Data.

get_hyperion(ifile[, piter, showlog, tnames, metaonly])

Get Hyperion Data.

get_sentinel1(ifile[, piter, showlog, tnames, metaonly])

Get Sentinel-1 Data.

get_sentinel2(ifile, *[, piter, showlog, tnames, ...])

Get Sentinel-2 Data.

get_sentinel2_metadata(ifile)

Get extra metadata from xml files which rasterio does not access.

get_spot(ifile[, piter, showlog, tnames, metaonly])

Get Spot DIMAP Data.

get_aster_zip(ifile[, piter, showlog, tnames, metaonly])

Get ASTER zip Data.

get_aster_metadata(ifile)

Get extra metadata from met files which rasterio does not access.

get_aster_hdf(ifile[, piter, showlog, tnames, metaonly])

Get ASTER hdf Data.

get_aster_ged(ifile[, piter, showlog, tnames, metaonly])

Get ASTER GED data.

get_aster_ged_bin(ifile)

Get ASTER GED binary format.

get_ternary(dat[, sunfile, clippercl, clippercu, ...])

Create a ternary image, with optional sunshading.

set_export_filename(dat, odir[, otype])

Set the export filename according to convention.

utm_to_south(dat)

Make sure all UTM labels are for southern hemisphere.

Module Contents#

class pygmi.rsense.iodefs.ImportData(parent=None)#

Bases: pygmi.misc.BasicModule

Import Data GUI - Interfaces with rasterio routines.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

setupui()#

Set up UI.

Return type:

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

get_sfile()#

Get the satellite filename.

saveproj()#

Save project data from class.

Return type:

None.

class pygmi.rsense.iodefs.ImportBatch(parent=None)#

Bases: pygmi.misc.BasicModule

Batch Import Data Interface.

This does not actually import data, but rather defines a list of datasets to be used by other routines.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

idir#

Input directory.

Type:

str

setupui()#

Set up UI.

Return type:

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

get_sfile(nodialog=False)#

Get the satellite filenames.

setsensor()#

Set the sensor band data.

Return type:

None.

saveproj()#

Save project data from class.

Return type:

None.

class pygmi.rsense.iodefs.ImportSentinel5P(parent=None)#

Bases: pygmi.misc.BasicModule

GUI import Sentinel 5P data and export to shapefile.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

setupui()#

Set up UI.

Return type:

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

clipchoice()#

Choose clip style.

Return type:

None.

loadshp()#

Load shapefile filename.

Return type:

None.

saveproj()#

Save project data from class.

Return type:

None.

get_5P_meta()#

Get 5P metadata.

Returns:

meta – Dictionary containing metadata.

Return type:

Dictionary

get_5P_data(meta)#

Get 5P data.

Parameters:

meta (Dictionary) – Dictionary containing metadata.

Returns:

gdf – geopandas dataframe.

Return type:

DataFrame

class pygmi.rsense.iodefs.ExportBatch(parent=None)#

Bases: pygmi.misc.ContextModule

GUI to export Raster File List.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

setupui()#

Set up UI.

Return type:

None.

click_ternary()#

Click ternary event.

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.

get_odir(odir='')#

Get output directory.

Parameters:

odir (str, optional) – Output directory submitted for testing. The default is ‘’.

Return type:

None.

pygmi.rsense.iodefs.calculate_toa(dat, showlog=print)#

Top of atmosphere correction.

Includes VNIR, SWIR and TIR bands.

Parameters:
  • dat (pygmi.raster.datatypes.Data) – PyGMI raster dataset

  • showlog (function, optional) – Routine to show text messages. The default is print.

Returns:

out – PyGMI raster dataset

Return type:

pygmi.raster.datatypes.Data

pygmi.rsense.iodefs.consolidate_aster_list(flist)#

Consolidate ASTER files from a file list, getting rid of extra files.

Parameters:

flist (list) – List of filenames.

Returns:

flist – List of filenames.

Return type:

list

pygmi.rsense.iodefs.convert_ll_to_utm(lon, lat)#

Convert latitude and longitude to UTM.

https://stackoverflow.com/a/40140326/4556479

Parameters:
  • lon (float) – Longitude.

  • lat (float) – latitude.

Returns:

epsg_code – EPSG code.

Return type:

str

pygmi.rsense.iodefs.etree_to_dict(t)#

Convert an ElementTree to dictionary.

From K3–rnc: https://stackoverflow.com/questions/7684333/converting-xml-to-dictionary-using-elementtree

Parameters:

t (Elementtree) – Root.

Returns:

d – Dictionary of ElementTree items.

Return type:

dictionary

pygmi.rsense.iodefs.export_batch(indata, odir, filt, *, tnames=None, piter=None, showlog=print, otype=None, sunfile=None, cell=25.0, alpha=0.75)#

Export a batch of files directly from satellite format to disk.

Parameters:
  • indata (dictionary) – Dictionary containing ‘RasterFileList’ as one of its keys.

  • odir (str) – Output Directory.

  • filt (str) – type of file to export.

  • tnames (list, optional) – list of band names to import, in order. 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.

  • otype (str) – output type of file, regular or RGB ternary (with possible sunshading)

  • sunfile (str) – either a filename of an external file to be used for sunshading, or an existing band name. the default is None.

  • cell (float) – Between 1 and 100 - controls sunshade detail. The default is 25.

  • alpha (float) – How much incident light is reflected (0 to 1). The default is .75.

Return type:

None.

pygmi.rsense.iodefs.files_to_rastermeta(allfiles, piter=iter, showlog=print)#

Import files to a RasterMeta item.

Parameters:
  • allfiles (list) – List of filenames.

  • piter (function, optional) – Progress bar iterable. Default is iter.

  • showlog (function, optional) – Routine to show text messages. The default is print.

Returns:

  • bands (dict) – Bands

  • tnames (dict) – Sensor types

  • filelist (list) – List of RasterMeta data.

pygmi.rsense.iodefs.get_data(ifile, *, piter=None, showlog=print, tnames=None, metaonly=False, bounds=None)#

Load 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

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • 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.

  • bounds (tuple) – Bounds of data to import as (left, bottom, right, top)

Returns:

dat – dataset imported

Return type:

list of pygmi.raster.datatypes.Data

pygmi.rsense.iodefs.get_from_rastermeta(ldata, *, piter=None, showlog=print, tnames=None, metaonly=False, bounds=None)#

Import data from a RasterMeta item.

For convenience a Data object is also accepted as input.

Parameters:
  • ldata (RasterMeta or pygmi.raster.datatypes.Data) – RasterMeta item.

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • tnames (list, optional) – list of band names to import, in order. The default is None.

  • metaonly (bool, optional) – Retrieve only the metadata for the files. The default is False.

  • bounds (tuple) – Bounds of data to import as (left, bottom, right, top)

Returns:

dat – List of data.

Return type:

list of pygmi.raster.datatypes.Data

pygmi.rsense.iodefs.get_emit(ifile, piter=None, showlog=print, tnames=None, metaonly=False)#

Get EMIT Data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • 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.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_modisv6(ifile, piter=None, showlog=print, tnames=None, metaonly=False)#

Get MODIS v006 data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • 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.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_landsat(ifilet, piter=None, showlog=print, tnames=None, metaonly=False)#

Get Landsat Data.

Parameters:
  • ifilet (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • 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.

Returns:

out – PyGMI raster dataset

Return type:

pygmi.raster.datatypes.Data

pygmi.rsense.iodefs.get_worldview(ifilet, piter=None, showlog=print, tnames=None, metaonly=False)#

Get WorldView Data.

Parameters:
  • ifilet (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • 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.

Returns:

out – PyGMI raster dataset

Return type:

pygmi.raster.datatypes.Data

pygmi.rsense.iodefs.get_hyperion(ifile, piter=None, showlog=print, tnames=None, metaonly=False)#

Get Hyperion Data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • 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.

Returns:

out – PyGMI raster dataset

Return type:

pygmi.raster.datatypes.Data

pygmi.rsense.iodefs.get_sentinel1(ifile, piter=None, showlog=print, tnames=None, metaonly=False)#

Get Sentinel-1 Data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • 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.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_sentinel2(ifile, *, piter=None, showlog=print, tnames=None, metaonly=False, bounds=None)#

Get Sentinel-2 Data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • 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.

  • bounds (tuple) – Bounds of data to import as (left, bottom, right, top)

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_sentinel2_metadata(ifile)#

Get extra metadata from xml files which rasterio does not access.

Parameters:

ifile (str) – Input filename.

Returns:

meta – Output metadata.

Return type:

dictionary

pygmi.rsense.iodefs.get_spot(ifile, piter=None, showlog=print, tnames=None, metaonly=False)#

Get Spot DIMAP Data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • 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.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_aster_zip(ifile, piter=None, showlog=print, tnames=None, metaonly=False)#

Get ASTER zip Data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • 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.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_aster_metadata(ifile)#

Get extra metadata from met files which rasterio does not access.

Parameters:

ifile (str) – Input filename.

Returns:

meta – Output metadata.

Return type:

dictionary

pygmi.rsense.iodefs.get_aster_hdf(ifile, piter=None, showlog=print, tnames=None, metaonly=False)#

Get ASTER hdf Data.

This function needs the original filename to extract the date.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • 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.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_aster_ged(ifile, piter=None, showlog=print, tnames=None, metaonly=False)#

Get ASTER GED data.

Parameters:
  • ifile (str) – filename to import

  • piter (function, optional) – Progress bar iterable. Default is None.

  • showlog (function, optional) – Routine to show text messages. The default is print.

  • 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.

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_aster_ged_bin(ifile)#

Get ASTER GED binary format.

Emissivity_Mean_Description: Mean Emissivity for each pixel on grid-box using all ASTER data from 2000-2010 Emissivity_SDev_Description: Emissivity Standard Deviation for each pixel on grid-box using all ASTER data from 2000-2010 Temperature_Mean_Description: Mean Temperature (K) for each pixel on grid-box using all ASTER data from 2000-2010 Temperature_SDev_Description: Temperature Standard Deviation for each pixel on grid-box using all ASTER data from 2000-2010 NDVI_Mean_Description: Mean NDVI for each pixel on grid-box using all ASTER data from 2000-2010 NDVI_SDev_Description: NDVI Standard Deviation for each pixel on grid-box using all ASTER data from 2000-2010 Land_Water_Map_LWmap_Description: Land Water Map using ASTER visible bands Observations_NumObs_Description: Number of values used in computing mean and standard deviation for each pixel. Geolocation_Latitude_Description: Latitude Geolocation_Longitude_Description: Longitude ASTER_GDEM_ASTGDEM_Description: ASTER GDEM resampled to NAALSED

Parameters:

ifile (str) – filename to import

Returns:

dat – dataset imported

Return type:

PyGMI raster Data

pygmi.rsense.iodefs.get_ternary(dat, sunfile=None, clippercl=1.0, clippercu=1.0, cell=25.0, alpha=0.75, piter=iter, showlog=print)#

Create a ternary image, with optional sunshading.

Parameters:
  • dat (list of pygmi.raster.datatypes.Data) – PyGMI Data.

  • sunfile (str, optional) – Sunshading band or filename. The default is None.

  • clippercl (float, optional) – Lower clip percentage for colour bar. The default is 1.

  • clippercu (float, optional) – Upper clip percentage for colour bar. The default is 1.

  • cell (float, optional) – Between 1 and 100 - controls sunshade detail. The default is 25.

  • alpha (float, optional) – How much incident light is reflected (0 to 1). The default is .75.

Returns:

newimg – list of PyGMI data.

Return type:

list of pygmi.raster.datatypes.Data.

pygmi.rsense.iodefs.set_export_filename(dat, odir, otype=None)#

Set the export filename according to convention.

Different satellite products have different simplified conventions for output filenames to avoid names getting too long.

Parameters:
  • dat (list of pygmi.raster.datatypes.Data.) – List of PyGMI data.

  • odir (str) – Output directory.

  • otype (str, optional.) – Output file type. Default is None.

Returns:

ofile – Output file name.

Return type:

str

pygmi.rsense.iodefs.utm_to_south(dat)#

Make sure all UTM labels are for southern hemisphere.

Parameters:

dat (list of pygmi.raster.datatypes.Data) – List of Data.

Returns:

dat – List of Data.

Return type:

list of pygmi.raster.datatypes.Data