geowatch.tasks.cold.prepare_ard module

geowatch.tasks.cold.prepare_ard.mask_value(vector, val)[source]

Build a boolean mask around a certain value in the vector.

Parameters:
  • vector – 1-d ndarray of values

  • val – values to mask on

Returns:

1-d boolean ndarray

geowatch.tasks.cold.prepare_ard.qabitval_array_HLS(packedint_array)[source]

Institute a hierarchy of qa values that may be flagged in the bitpacked value.

fill > cloud > shadow > snow > water > clear

Parameters:

packedint – int value to bit check

Returns:

offset value to use

geowatch.tasks.cold.prepare_ard.qabitval_array(packedint_array)[source]

Institute a hierarchy of qa values that may be flagged in the bitpacked value. fill > cloud > shadow > snow > water > clear :Parameters: packedint – int value to bit check

Returns:

offset value to use

geowatch.tasks.cold.prepare_ard.qabitval_array_c2(packedint_array)[source]

Institute a hierarchy of qa values that may be flagged in the bitpacked value for c2

fill > cloud > shadow > snow > water > clear

Parameters:

packedint – int value to bit check

Returns:

offset value to use

geowatch.tasks.cold.prepare_ard.load_data(file_name, gdal_driver='GTiff')[source]

Converts a GDAL compatable file into a numpy array and associated geodata. The rray is provided so you can run with your processing - the geodata consists of the geotransform and gdal dataset object if you’re using an ENVI binary as input, this willr equire an associated .hdr file otherwise this will fail. This needs modifying if you’re dealing with multiple bands.

VARIABLES file_name : file name and path of your file

RETURNS image array (geotransform, inDs)

geowatch.tasks.cold.prepare_ard.single_image_stacking_hls(source_dir, out_dir, logger, config, folder, is_partition=True, clear_threshold=0, low_date_bound=None, upp_date_bound=None)[source]

unzip single image, convert bit-pack qa to byte value, and save as numpy :param source_dir: the parent folder to save image ‘folder’ :param out_dir: the folder to save result :param folder: the folder name of image :param logger: the handler of logger file :param config :param is_partition: True, partition each image into blocks; False, save original size of image :param clear_threshold: threshold of clear pixel percentage, if lower than threshold, won’t be processed :param low_date_bound: the lower date of user interested year range :param upp_date_bound: the upper date of user interested year range :return:

geowatch.tasks.cold.prepare_ard.single_image_stacking_hls14(out_dir, logger, config, folder, is_partition=True, clear_threshold=0, low_date_bound=None, upp_date_bound=None)[source]

unzip single image, convert bit-pack qa to byte value, and save as numpy :param source_dir: the parent folder to save image ‘folder’ :param out_dir: the folder to save result :param folder: the folder name of image :param logger: the handler of logger file :param config :param is_partition: True, partition each image into blocks; False, save original size of image :param clear_threshold: threshold of clear pixel percentage, if lower than threshold, won’t be processed :param low_date_bound: the lower bound of user interested date range :param upp_date_bound: the upper bound of user interested date range :return:

geowatch.tasks.cold.prepare_ard.single_image_stacking(tmp_path, source_dir, out_dir, folder, clear_threshold, path_array, logger, config, is_partition=True, low_date_bound=None, upp_date_bound=None)[source]

unzip single image, convert bit-pack qa to byte value, and save as numpy :param tmp_path: tmp folder to save unzip image :param source_dir: image folder save source zipped files :param out_dir: the folder to save result :param folder: the folder name of image :param clear_threshold: threshold of clear pixel percentage, if lower than threshold, won’t be processed :param path_array: path array has the same dimension of inputted image, and the pixel value indicates

the path which the pixel belongs to; if path_array == none, we will use all path

Parameters:

logger – the handler of logger file

:param config :param is_partition: True, partition each image into blocks; False, save original size of image :param low_date_bound: the lower bound of user interested year range :param upp_date_bound: the upper bound of user interested year range :return:

geowatch.tasks.cold.prepare_ard.single_image_stacking_collection2(tmp_path, source_dir, out_dir, folder, clear_threshold, logger, config, bounds, is_partition=True, low_date_bound=None, upp_date_bound=None)[source]

for collection 2 :param tmp_path: tmp folder to save unzip image :param source_dir: image folder save source zipped files :param out_dir: the folder to save result :param folder: the folder name of image :param clear_threshold: threshold of clear pixel percentage, if lower than threshold, won’t be processed :param logger: the handler of logger file :param config :param is_partition: True, partition each image into blocks; False, save original size of image :param low_date_bound: the lower bound of user interested date range :param upp_date_bound: the upper bound of user interested date range :param bounds :return:

geowatch.tasks.cold.prepare_ard.checkfinished_step1(tmp_path)[source]
Parameters:

tmp_path

Returns:

geowatch.tasks.cold.prepare_ard.checkfinished_step2(out_dir, n_cores)[source]
Parameters:
  • out_dir

  • n_cores

Returns:

geowatch.tasks.cold.prepare_ard.checkfinished_step3_partition(out_dir)[source]
Parameters:

out_dir

Returns:

geowatch.tasks.cold.prepare_ard.checkfinished_step3_nopartition(out_dir)[source]
Parameters:

out_dir

Returns:

geowatch.tasks.cold.prepare_ard.get_extent(extent_geojson, res, buf=0)[source]

read shapefile of a tile from an S3 bucket, and convert projection to be aligned with sample image. arg:

‘extent_geojson’: sharply geojson object res: planet resolution

Returns:

(float, float, float, float), (int, int)) tuple

geowatch.tasks.cold.prepare_ard.get_feature(shp, id)[source]
geowatch.tasks.cold.prepare_ard.explode(coords)[source]

Explode a GeoJSON geometry’s coordinates object and yield coordinate tuples. As long as the input is conforming, the type of the geometry doesn’t matter.

geowatch.tasks.cold.prepare_ard.bbox(f)[source]