odeon.scripts.sample_grid.SampleGrid

class odeon.scripts.sample_grid.SampleGrid(verbose, input_file, output_pattern, image_size_pixel, resolution, strict_inclusion=False, shift=False, tight_mode=False)

Callable class as entry point of the sample_grid tool

__init__(verbose, input_file, output_pattern, image_size_pixel, resolution, strict_inclusion=False, shift=False, tight_mode=False)
Parameters
  • verbose (bool) – verbose level

  • input_file (str) – shapefile containing the zones of interest for one “departement”

  • output_pattern (str) – filename pattern used for each zone

  • image_size_pixel (int) – number of pixel of an images

  • resolution (Union[float, list of float]) – resolution for x and y dimension if different

  • strict_inclusion (boolean) – True if the tile must be strictly included in the polygonal shape

  • shift (boolean) – True to shift samples by half the size of a tile

  • tight_mode (boolean) – sample points stick to the upper left corner

Methods

__init__(verbose, input_file, ...[, ...])

param verbose

verbose level

generate_csv(geometry_list, filename_list, ...)

Generate a list of coordinates (x,y) for each geometry and save this list :param geometry_list: list of geometry (square shaped areas) :type geometry_list: list of geometry :param filename_list: list of filename that will :type filename_list: list :param side: size of image in CRS unit :type side: list of float :param crs: coordinate system :type crs: dict :param strict_inclusion: True if the tile must be strictly included in the polygonal shape :type strict_inclusion: boolean :param shift: True to shift samples by half the size of a tile :type shift: boolean :param tight_mode: sample points stick to the upper left corner :type tight_mode: boolean :param verbose: verbose level :type verbose: bool

generate_filename(output_pattern, no_of_samples)

Returns a list of filenames with complete path :param output_pattern: the pattern to follow when generating filenames :type output_pattern: str :param no_of_samples: number of filename to generate :type no_of_samples: int

get_geometries_from_shp(shapefile)

Returns a list of geometries ordered by x, then y :param shapefile: shapefile containing polygons (usually within a "departement") :type shapefile: str

included(x, y, side, geometry)

save_output(coordinates, filename, side, ...)

Save coordinates and, if verbose is on, save shapefiles (area and center) for visual inspection :param coordinates: list of coordinates :type coordinates: list :param filename: output file containing the coordinate in csv format :type filename: str :param side: size of an image in CRS unit :type side: list of float :param crs: coordinate system :type crs: dict :param verbose: verbose level :type verbose: bool

setup_output(output_pattern)

Create the folder for the files created during the sampling :param output_pattern: the pattern to follow for the files