iota2.common.file_utils

This module contains a lot of useful file manipulation functions

Functions

array_to_raster(array, output, model[, driver])

convert a numpy array to a gdal raster

assembleTile_Merge(raster_list, ...[, ...])

usage : wrapper around gdal_merge utility

common_pix_type_to_otb(string)

Convert a name to an otb piixel type :param string: the name to convert

conf_coordinates_csv(csvPaths)

IN : csvPaths [string] : list of path to csv files ex : ["/path/to/file1.csv","/path/to/file2.csv"] OUT : out [list of lists] : containing csv's coordinates

date_interval(date_min, date_max, temp_res)

dateMin [string] : Ex -> 20160101 dateMax [string] > dateMin tr [int/string] -> temporal resolution

detect_csv_delimiter(csv_file)

detect csv delimiter

ensure_dir(dirname[, raise_exe])

Ensure that a named directory exists; if it does not, attempt to create it.

file_search_and(PathToFolder, AllPath, *names)

search all files in a folder or sub folder which contains all names in their name

file_search_reg_ex(path_file)

get files by regEx

findCurrentTileInString(string, allTiles)

IN: string [string]: string where we want to found a string in the string list 'allTiles' allTiles [list of strings]

find_and_replace_file(input_file, ...)

search string in file and replace by the new one into an output file

gen_confusion_matrix(csv_f, AllClass)

IN: csv_f [list of list] : comes from conf_coordinates_csv function.

getDateFromString(vardate)

get date from string date :type vardate: str :param vardate: input date ex : 20160101

get_date_landsat(path_landsat, tiles)

Get the min and max dates for the given tile.

get_date_s2(path_s2, tiles)

Get the min and max dates for the given tile.

get_date_s2_s2c(path_s2, tiles)

Get the min and max dates for the given tile.

get_feat_stack_name(list_indices[, ...])

usage : get Feature Stack name :type list_indices: List[str] :param list_indices: the features list :type list_indices: list(string) :param user_feat_path: the path to images :type user_feat_path: string :type user_feat_pattern: Optional[str] :param user_feat_pattern: contains features name separated by comma :type user_feat_pattern: string

get_image_pixel_type(raster_in)

Get raster pixel type of raster_in from GetDataTypeName() :param INPUT: - raster_in: gdal raster datatse or osgeo.gdal.Dataset object :param OUTPUT: - GDAL raster pixel type: str

get_iota2_project_dir()

get_list_tile_from_model(model_in, ...)

type model_in

str

get_nb_date_in_tile(date_in_file[, display, ...])

usage : get available dates in file dateInFile [string] : path to txt containing one date per line raw_dates [bool] flag use to return all available dates

get_raster_extent(raster_in)

Get raster extent of raster_in from GetGeoTransform() :param INPUT: - raster_in: input raster :param OUTPUT: - ex: extent with [minX,maxX,minY,maxY]

get_raster_n_bands(raster)

usage get raster's number of bands

get_raster_projection_epsg(file_name)

usage get raster EPSG projection code

get_raster_resolution(raster_in)

IN : rasterIn [string]:path to raster

is_writable_directory(directory_path)

ensure a directory is writable :type directory_path: str :param directory_path: the directory to be tested

md5(fname)

return the md5 of a file :type fname: str :param fname: the file name

memory_usage_psutil([unit])

Return the memory usage :param unit: the expect unit for return ram (MB or GB)

pix_to_geo(raster, col, row)

return geographical coordinates of col, row position

read_raster(name[, data, band])

Open raster and return metadate information about it.

run(cmd[, desc, env, logger])

Launch a system command and raise an execption if fail

sort_by_first_elem(my_list)

Example 1:

split_list(InList, nbSplit)

IN : InList [list] nbSplit [int] : number of output fold

update_directory(src, dst)

verify_import(module_path)

Check if a module can be imported

write_cmds(path, cmds[, mode])

write_new_file(new_file, file_content)

write a new file

Classes

RemoveInStringList(*args)

decorator used to remove element in return list according to strings

defaultdict

defaultdict(default_factory=None, /, [...]) --> dict with default factory

timedelta

Difference between two datetime values.