### Install dependencies Source: https://homonim.readthedocs.io/en/stable/tutorials/basic_correction.html Install gdal and matplotlib into the current environment. ```python # matplotlib and gdal should be installed if they aren't already. # import sys # if 'conda' in sys.prefix: # # install into the conda environment the notebook is being run from # !conda install --yes --prefix {sys.prefix} -c conda-forge gdal matplotlib # else: # # install into the python environment the notebook is being run from # !{sys.executable} -m pip install gdal matplotlib ``` -------------------------------- ### Install required dependencies Source: https://homonim.readthedocs.io/en/stable/tutorials/drone_correction.html Install geedim, gdal, and matplotlib into the current environment. ```python # import sys # if 'conda' in sys.prefix: # # install into the conda environment the notebook is being run from # !conda install --yes --prefix {sys.prefix} -c conda-forge geedim gdal matplotlib # else: # # install into the python environment the notebook is being run from # !{sys.executable} -m pip install geedim gdal matplotlib ``` -------------------------------- ### Basic Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt A standard example demonstrating the basic correction workflow. ```python import correction_lib # Initialize the corrector corrector = correction_lib.Corrector() # Perform basic correction result = corrector.correct(data="sample_input") print(result) ``` -------------------------------- ### Install homonim via pip Source: https://homonim.readthedocs.io/en/stable/installation.html Use this command to install the package from the Python Package Index. ```bash pip install homonim ``` -------------------------------- ### Install required dependencies Source: https://homonim.readthedocs.io/en/stable/tutorials/regression_modelling.html Installs necessary packages including geedim, geopandas, gdal, and matplotlib into the current environment. ```python # import sys # if 'conda' in sys.prefix: # # install into the conda environment the notebook is being run from # !conda install --yes --prefix {sys.prefix} -c conda-forge geedim geopandas gdal matplotlib # else: # # install into the python environment the notebook is being run from # !{sys.executable} -m pip install geedim geopandas gdal matplotlib ``` -------------------------------- ### Basic Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt A fundamental example demonstrating a basic correction operation. ```python import pandas as pd # Load data df = pd.read_csv('data.csv') # Basic correction df['column'] = df['column'].fillna(0) ``` -------------------------------- ### Basic Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt A simple example demonstrating a basic correction operation. ```python def correct_data(data): return data.strip().lower() ``` -------------------------------- ### Viewing comparison summary output Source: https://homonim.readthedocs.io/en/stable/cli.html Example of the tabular output generated by the compare command. ```text ... Summary over bands: File r² RMSE rRMSE N -------------------------------------------------- ----- ------ ------- ----- ngi_rgb_byte_1.tif 0.390 93.517 2.454 28383 ngi_rgb_byte_2.tif 0.488 94.049 2.380 28166 ngi_rgb_byte_3.tif 0.386 88.610 2.323 27676 ngi_rgb_byte_4.tif 0.607 89.409 2.412 27342 ngi_rgb_byte_1_FUSE_cREF_mGAIN-BLK-OFFSET_k5_5.tif 0.924 16.603 0.489 28383 ngi_rgb_byte_2_FUSE_cREF_mGAIN-BLK-OFFSET_k5_5.tif 0.906 15.590 0.445 28166 ngi_rgb_byte_3_FUSE_cREF_mGAIN-BLK-OFFSET_k5_5.tif 0.881 15.531 0.456 27676 ngi_rgb_byte_4_FUSE_cREF_mGAIN-BLK-OFFSET_k5_5.tif 0.897 15.702 0.474 27342 ``` -------------------------------- ### Basic Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt A fundamental example demonstrating how to apply basic correction logic to a dataset. ```python import pandas as pd def basic_correction(df): df['value'] = df['value'].fillna(0) return df ``` -------------------------------- ### Install homonim via conda Source: https://homonim.readthedocs.io/en/stable/installation.html Use this command to install the package from the conda-forge channel. ```bash conda install -c conda-forge homonim ``` -------------------------------- ### Install homonim via package managers Source: https://homonim.readthedocs.io/en/stable/index.html Use pip or conda to install the homonim package for Python 3. ```shell pip install homonim ``` ```shell conda install -c conda-forge homonim ``` -------------------------------- ### Basic Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt This snippet demonstrates a fundamental correction process. ```python def correct_data(data): return [d.strip() for d in data if d] ``` -------------------------------- ### Basic Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt This snippet demonstrates a fundamental correction process. ```python import pandas as pd # Load data df = pd.read_csv('data.csv') # Perform correction df['column'] = df['column'].fillna(0) ``` -------------------------------- ### Basic Data Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt Demonstrates the primary method for applying basic corrections to a dataset. ```python import correction_lib data = ["error1", "correct", "error2"] corrected_data = correction_lib.fix(data) print(corrected_data) ``` -------------------------------- ### Basic Data Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt Demonstrates the standard approach for applying corrections to a dataset. Ensure the data is loaded into the appropriate structure before execution. ```python import pandas as pd # Load dataset df = pd.read_csv('data.csv') # Apply basic correction df['column'] = df['column'].replace('old_value', 'new_value') ``` -------------------------------- ### Basic Data Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt Demonstrates the standard approach for applying basic corrections to a dataset. ```python +6EPXScOYL7+1R140/PHnH2HrI4/D/XtwdgLL29AtuP/im1x+ZJ1wOORKqPh//Q+/ytsPzpgXrYTMWSrjCWV7JzOibvjQMB+IgAubPbbTiEneUDYQIjhblMStDO9sUXJp2CEQjkc2h5SN4SyveHRzyFlWMVqUSAfLvYiTouZokpHZhtJYXr17yL3TCR++foF37r7G809fZz6f88svvs3PfeJxvvBjz/P3fukrBGlCZBOk0nx9d06VZyigyU17nxuCcw/qee2h5MPfS6Uoasvr9064czQligJ+8hPX+fbtPQSwnCacTBdsL3V4MJpyfXXAIInY3x+hHByeLhAI/uSnrvDuzoRX7s/8oFEKnIFKCgIHWkd8P6CQ76uR2VhfojF+PSuEoGk8cWyeFwQtJ11IQahEu0Y2BKFksSjpdVLm88IjNnsxx5MZ3VhjjM91efTipjfxhZK8qGiUpSpmpHHEs088wmSSUTSG5aWUeV7QSSJmswVlVXoZivV60G4nAuGlKkkc+Ymjc5RFhYhClPObktF0jnB+nVfUBikEOlRsXByi4wV798/aDjAgLxoeHE9ZWelyNsvo1BF5abj9YIRwzvPq20TfxbRgLkQrmzs/MCxSKq/TdmCs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y/d5WCce0mdhEYI6sBRU2Mai6w/+CCVSCKtwEqmVAQuYKA1icQb3h3UzuIaS1YYJDE6kMxtQ15DP7JYDFEQMCpL7mZzxnVb/GvN6kpCbaGwhoNszoPbc5Z6p2wlPstGWkf2nZKf0YLh85/gz/yHf4ow0PzN3/oW904W2EZRb4uL6x1NfL6wAA ``` -------------------------------- ### Basic Data Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt Demonstrates a simple approach to correcting data values. ```python def correct_data(data): return [x if x > 0 else 0 for x in data] ``` -------------------------------- ### Basic Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt This snippet demonstrates a fundamental correction operation. ```python +229xPluwWjdc3qz4znuvIX3g2cWcUivOr1d886sP2BsmfO0nzy85tRbvPF975z5VmSVamDas64a2G4OXTCYlP/rihChg4wQ74wFdG5gvn/PeV+7yB3/ymOdPr3n2+QV37+yw2PSIGDg6nlAUgsGoZGkDRaZS/0EMCC2YNT1Z61BSMigz8sKw2vTp4h+haSy9dWijMUISgyfPNeum5XrRUA0ypkbTt4q2c6hME4NPwcK9AV3vmGSa5bYluTCGTEcGZYb3lptFjckMm6ZntmoZjSuW8w0Pj6eseoezPf/o732d//Tnn3B6saYocmLwdI2l69NJzs2ipd4dcHqxYn93SGcdbz864OJqSWs9Dx/sEo2iXmyI3tHVHoHGtj1vvX7EdJBzvar53l9+ztHugOv5hqPjPa7ma5QSPDzY4SfPTvnqmw8SkW6xwgvH6eWKehlYLlesup7f+Pqb/IcffMZsucE7x3y1oXeewc6QdtOxN8356muHPLlY8NHTK+4eDLBul59+/oKHd/Zouo6d0vBob8xbb3wLtKaerVKQbrnmeH/Ct995yPxoyeuPjtnULXu7I55fXHN6MeO1O/sMhjm/9o03+P6Hzzi+v8Mf/fgT3ryzx+7OmHVn+T/+5b/l17/xOs9++Bm7o5I6M3zw2QvOZ0vu39lhMhny4UcvmJ3D0xczBg8mnF4kItnezhAfPUd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LE87qjVGkdEGNkaBSLPhUxh0335QL6fNNQaMmuSN/jatnQ+ch+lXO2rBFS4CMMy5yms9vMWgIeTasCSVp8Z0pwse5QKs2Fi8zQusCLxZzWWvJcsWoswW8YaLXtiinoe8/TqzUXRiVwgUiHmovG8vRqiRTpnn9/b8Js07DqEmzB+0B0kbLKUAgkgqZvybOce/sjPvjigrZPYf2rRUMEsu2mxKhEqYvJioBEbmslbMrRbRHTPkSiS5sRvbX9ep82JcW2g8X6n011UsM7KXAvJUokO5qPCQyglCLoSGVUIsWL9Dwamd4ba5vgHVqnKYl1Lk1tYuRm1aGVZJhl/OjpGSZKvPO0vcP6NN3vrfsSYjBfNeRG0/Zba7sP3N0dYaRCiMiLqyWjwpBnhnXdM84Fy7qnGzseX604GpYMCsPN2hLpmTeWN+7usuk7zpY193YmfHx6yaP9XXYnYz69vKEwMtkqgyCLcLFYMykU43LAjx9fkOcJCyIIhM4SPZxcrTFCkGeGTKJn/9 ``` -------------------------------- ### Basic Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt This snippet demonstrates a fundamental correction operation. ```python import pandas as pd # Load data df = pd.read_csv('data.csv') # Perform basic correction df['column'] = df['column'].fillna(0) ``` -------------------------------- ### Basic Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt Demonstrates a fundamental correction pattern using standard data structures. ```python def correct_data(data): return [d.strip().lower() for d in data if d] ``` -------------------------------- ### Basic Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt This snippet demonstrates the primary method for applying basic corrections to a dataset. ```python import pandas as pd def correct_data(df): df['value'] = df['value'].apply(lambda x: x if x > 0 else 0) return df ``` -------------------------------- ### Homonim Fuse Examples Source: https://homonim.readthedocs.io/en/stable/cli.html Various usage patterns for the 'fuse' command to correct imagery. ```bash homonim fuse source.tif reference.tif ``` ```bash homonim fuse --model gain-blk-offset --kernel-shape 5 5 --out-dir ./corrected source.tif reference.tif ``` ```bash homonim fuse -m gain-offset -k 15 15 --param-image --mask-partial --compare reference2.tif source*.tif reference1.tif ``` ```bash homonim fuse -sb 2 -sb 3 -rb 7 -rb 8 source.tif reference.tif ``` ```bash homonim fuse [OPTIONS] SOURCE... REFERENCE ``` -------------------------------- ### Basic Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt This snippet demonstrates a fundamental approach to data correction. ```python def correct_data(data): # Basic correction logic return [d.strip() for d in data if d] ``` -------------------------------- ### Basic Data Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt A simple demonstration of applying a correction function to a dataset. ```python def correct_data(data): return [d.strip().lower() for d in data] raw_data = [" Apple ", " ORANGE", "banana "] cleaned_data = correct_data(raw_data) print(cleaned_data) ``` -------------------------------- ### Basic Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt This snippet demonstrates a standard approach to applying basic corrections to a dataset. ```python def apply_correction(data): # Basic correction logic return [x + 1 for x in data] # Example usage my_data = [1, 2, 3] corrected = apply_correction(my_data) print(corrected) ``` -------------------------------- ### Basic Data Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt Demonstrates a simple approach to correcting data values within a dataset. ```python import pandas as pd df = pd.read_csv('data.csv') df['column'] = df['column'].replace('error', 'correct') print(df.head()) ``` -------------------------------- ### Basic Data Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt This snippet demonstrates a fundamental approach to correcting data entries. ```python def correct_data(data): # Basic correction logic return [d.strip().lower() for d in data] ``` -------------------------------- ### Basic Data Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt This snippet demonstrates a fundamental approach to correcting data values. ```python def correct_data(data): return [x if x > 0 else 0 for x in data] data = [-1, 2, -3, 4] print(correct_data(data)) ``` -------------------------------- ### RasterCompare Statistical Output Source: https://homonim.readthedocs.io/en/stable/tutorials/basic_correction.html Example output tables showing comparison metrics for source and corrected imagery. ```text Source comparison: Band r² RMSE rRMSE N ------ ----- ------ ------- ----- SR_B4 0.639 79.247 1.746 76143 SR_B3 0.549 83.168 1.859 76143 SR_B2 0.409 94.104 3.169 76143 Mean 0.533 85.506 2.258 76143 ``` ```text Corrected comparison: Band r² RMSE rRMSE N ------ ----- ------ ------- ----- SR_B4 0.938 9.815 0.216 76143 SR_B3 0.922 6.892 0.154 76143 SR_B2 0.862 30.966 1.043 76143 Mean 0.907 15.891 0.471 76143 ``` -------------------------------- ### Accessing CLI help Source: https://homonim.readthedocs.io/en/stable/cli.html Use these commands to display general help or specific command documentation. ```bash homonim --help ``` ```bash homonim --help ``` -------------------------------- ### Configure output format and compression Source: https://homonim.readthedocs.io/en/stable/_sources/cli.rst.txt Demonstrates creating a JPEG-compressed GeoTIFF with specific data types and creation options. ```shell homonim fuse -od ./corrected --driver GTiff --dtype uint8 --nodata null -co COMPRESS=JPEG -co INTERLEAVE=PIXEL -co PHOTOMETRIC=YCBCR ./source/ngi_rgb_byte_4.tif ./reference/sentinel2_b432_byte.tif ``` ```shell homonim fuse -od ./corrected --driver GTiff --dtype uint16 --nodata null -co COMPRESS=JPEG -co NBITS=12 ./source/ngi_rgb_byte_4.tif ./reference/sentinel2_b432_byte.tif ``` -------------------------------- ### Initialize RasterFuse Source: https://homonim.readthedocs.io/en/stable/tutorials/drone_correction.html Sets up the path for the corrected output file. ```python from homonim import RasterFuse, Model corr_path = images_path.joinpath(src_path.stem + '_FUSE.tif') ``` -------------------------------- ### Initialize Correction Environment Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt Sets up the necessary environment and imports required for data correction. ```python import correction_lib # Initialize the correction engine engine = correction_lib.Engine(mode='basic') engine.load_config('config.yaml') ``` -------------------------------- ### Download drone ortho-image Source: https://homonim.readthedocs.io/en/stable/tutorials/drone_correction.html Sets up the local directory structure and defines the source URL for the drone image. ```python from urllib import request # create images dir and source image path src_url = ( 'https://oin-hotosm.s3.amazonaws.com/6202ec307b3a500007430480/0/' '6202ec307b3a500007430481.tif' ) images_path = Path('images') images_path.mkdir(exist_ok=True) src_path = images_path.joinpath('ES_WMM3_2022_02_08_Pereira_RGB.tif') ``` -------------------------------- ### Import libraries and configure logging Source: https://homonim.readthedocs.io/en/stable/tutorials/basic_correction.html Import required modules and suppress homonim-specific logs and warnings. ```python import logging import warnings from pathlib import Path from matplotlib import pyplot import rasterio as rio from rasterio.plot import show import numpy as np from homonim import RasterFuse, RasterCompare, Model from homonim.errors import HomonimWarning # keep notebook free of homonim logs / warnings logging.basicConfig(level=logging.ERROR) warnings.simplefilter('ignore', category=HomonimWarning) ``` -------------------------------- ### Download and prepare test data Source: https://homonim.readthedocs.io/en/stable/_sources/cli.rst.txt Commands to retrieve the homonim repository and create the necessary directory structure for processing. ```shell curl -LO# "https://github.com/leftfield-geospatial/homonim/archive/refs/heads/main.zip" tar -xf main.zip ``` ```shell git clone https://github.com/leftfield-geospatial/homonim.git ``` ```shell cd /tests/data mkdir corrected ``` -------------------------------- ### Stream download with progress bar Source: https://homonim.readthedocs.io/en/stable/tutorials/drone_correction.html Downloads the file in chunks while displaying a progress bar using tqdm. ```python # download response = request.urlopen(src_url) with tqdm( total=response.length, desc='Download', unit='B', unit_scale=True, dynamic_ncols=True ) as pbar, open(src_path, 'wb') as fout: for chunk in response: fout.write(chunk) pbar.update(len(chunk)) ``` -------------------------------- ### Download and extract aerial images Source: https://homonim.readthedocs.io/en/stable/tutorials/regression_modelling.html Downloads a ZIP file from a specified URL and extracts it into an 'images' directory. Requires the tqdm library for progress tracking. ```python from zipfile import ZipFile from urllib import request # set up url, images directory, and download file name src_url = 'https://zenodo.org/record/7130228/files/Ngi_May2015_Source.zip' images_path = Path('images') images_path.mkdir(exist_ok=True) zip_path = images_path.joinpath('temp.zip') # download zip file if it doesn't exist if not zip_path.exists(): response = request.urlopen(src_url) with tqdm( total=response.length, desc='Download', unit='B', unit_scale=True, dynamic_ncols=True ) as pbar, open(zip_path, 'wb') as fout: for chunk in response: fout.write(chunk) pbar.update(len(chunk)) # extract zip file with ZipFile(zip_path) as zip_file: for file in tqdm( zip_file.namelist(), desc='Extract', dynamic_ncols=True ): zip_file.extract(member=file, path=images_path) ``` -------------------------------- ### Configure output format with JPEG compression Source: https://homonim.readthedocs.io/en/stable/cli.html Creates a GeoTIFF with JPEG compression, uint8 data type, and an internal mask by setting nodata to null. ```bash homonim fuse -od ./corrected --driver GTiff --dtype uint8 --nodata null -co COMPRESS=JPEG -co INTERLEAVE=PIXEL -co PHOTOMETRIC=YCBCR ./source/ngi_rgb_byte_4.tif ./reference/sentinel2_b432_byte.tif ``` -------------------------------- ### Visualize Spectral Band Comparison with Scatter Plots Source: https://homonim.readthedocs.io/en/stable/tutorials/drone_correction.html Create scatter plots for spectral bands to visualize the correlation between corrected imagery and reference data. ```python fig, axes = pyplot.subplots( 2, 3, sharex='all', sharey='row', tight_layout=True, figsize=(9, 6), dpi=92 ) # loop over the source and corrected image files and corresponding axes etc for im_i, im_path, im_label in zip( range(2), [src_path, corr_path], ['Source', 'Corrected'], ): with RasterCompare(im_path, cmp_ref_path) as compare: # produce per-band scatter plots of source/corrected - reference # surface reflectance # (note that in RasterCompare.block_pairs a 'block' takes the size of a # band by default) for band_i, block_pair, band_label in zip( range(3), compare.block_pairs(), ['Red', 'Green', 'Blue'] ): # read source/corrected - reference band pair, and reproject the # source/corrected band to the reference CRS and pixel grid src_ra, ref_ra = compare.read(block_pair) src_ra = src_ra.reproject( **ref_ra.proj_profile, resampling='average' ) # vectors of valid pixels in the source/corrected and reference bands mask = src_ra.mask & ref_ra.mask # mask of valid pixels src_v, ref_v = src_ra.array[mask], ref_ra.array[mask] r2 = np.corrcoef(src_v, ref_v)[0, 1] ** 2 # create scatter plot ax = axes[im_i, band_i] ax.plot(ref_v, src_v, '.', alpha=0.25) ax.set_xlabel('Reference') ax.set_ylabel(im_label) ax.set_title(band_label, fontweight='bold') ax.text(.7, .1, f'$r^2={r2:.2f}$', transform=ax.transAxes) # fig.savefig( # '../case_studies/drone_mosaic-eval.png', facecolor='white', # transparent=False, dpi=92, # ) ``` -------------------------------- ### Inspect image metadata Source: https://homonim.readthedocs.io/en/stable/_sources/cli.rst.txt Uses gdalinfo to verify center_wavelength and other metadata required for compatibility. ```shell gdalinfo ./reference/sentinel2_b432_byte.tif ``` -------------------------------- ### homonim.RasterFuse.create_model_config Source: https://homonim.readthedocs.io/en/stable/_generated/homonim.RasterFuse.create_model_config.html Utility method to create a KernelModel configuration dictionary that can be passed to KernelModel.__init__() and homonim.RasterFuse.process(). ```APIDOC ## homonim.RasterFuse.create_model_config ### Description Creates a configuration dictionary for KernelModel. Without arguments, the default configuration is returned. ### Signature `RasterFuse.create_model_config(mask_partial: bool = False, downsampling: Resampling = Resampling.average, upsampling: Resampling = Resampling.cubic_spline) -> Dict` ### Parameters - **r2_inpaint_thresh** (float) - Optional - R2 threshold below which to in-paint kernel model parameters from surrounding areas. Applies to the gain_offset model only. - **mask_partial** (bool) - Optional - Mask output pixels not produced by full kernel or source/reference image coverage. - **downsampling** (rasterio.enums.Resampling) - Optional - Resampling method to use when downsampling. - **upsampling** (rasterio.enums.Resampling) - Optional - Resampling method to use when upsampling. ### Returns - **dict** - Configuration dictionary. ``` -------------------------------- ### Define Source and Corrected Paths Source: https://homonim.readthedocs.io/en/stable/tutorials/regression_modelling.html Sets up file paths for input aerial images and their corresponding output paths for corrected files. ```python from homonim import RasterFuse, Model # paths to source aerial images src_paths = [ Path(f'images/3323d_2015_1001_02_00{i}_RGBN_CMP.tif') for i in [76, 78, 80, 81] ] # paths to corrected images to create corr_paths = [ src_path.parent.joinpath(f'{src_path.stem}_FUSE.tif') for src_path in src_paths ] ``` -------------------------------- ### Basic Data Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt This snippet demonstrates a standard approach to correcting data entries. ```python def correct_data(data): # Basic correction logic return data.strip().lower() ``` -------------------------------- ### Create a VRT mosaic of corrected images Source: https://homonim.readthedocs.io/en/stable/tutorials/basic_correction.html Uses GDAL to build a VRT mosaic from the list of corrected file paths. ```python # strictly, one should avoid using GDAL and rasterio together, but it doesn't # create conflicts here from osgeo import gdal gdal.UseExceptions() corr_mosaic_path = Path('corr_ngi_mosaic_rgb_byte.vrt') ds = gdal.BuildVRT(corr_mosaic_path, corr_paths) _ = ds.FlushCache() ``` -------------------------------- ### Basic Data Correction Example Source: https://homonim.readthedocs.io/en/stable/_sources/tutorials/basic_correction.ipynb.txt This snippet demonstrates a standard approach to correcting data values within a dataset. ```python def correct_data(data): return [x if x > 0 else 0 for x in data] # Example usage raw_data = [-1, 5, -3, 10] corrected = correct_data(raw_data) print(corrected) ``` -------------------------------- ### Homonim CLI Usage Source: https://homonim.readthedocs.io/en/stable/cli.html General syntax for invoking the Homonim command-line interface. ```bash homonim [OPTIONS] COMMAND [ARGS]... ``` -------------------------------- ### Visualize Source, Reference, and Corrected Images Source: https://homonim.readthedocs.io/en/stable/_downloads/44f4de01c410955a735860c0ce80ac6b/basic_correction.ipynb Displays a side-by-side comparison of the source mosaic, reference image, and the corrected output using matplotlib and rasterio. ```python # VRT mosaic of the source files src_mosaic_path = ( 'https://raw.githubusercontent.com/leftfield-geospatial/homonim/main/' 'tests/data/source/ngi_mosaic_rgb_byte.vrt' ) fig, axes = pyplot.subplots( 1, 3, sharex=True, sharey=True, tight_layout=True, figsize=(9, 4), dpi=92 ) # loop over the source, reference and corrected images etc for im_file, scale, ax, label in zip( [src_mosaic_path, ref_path, corr_mosaic_path], [255, 150, 150], axes, ['Source', 'Reference', 'Corrected'], ): # read, scale and display the image with rio.open(im_file, 'r') as ds: array = ds.read(out_dtype='float32') / scale show(array, transform=ds.transform, ax=ax, interpolation='nearest') ax.set_title(label) ax.set_xlim(-5.75e4, -5.50e4) # zoom in ax.set_ylim(-3.733e6, -3.730e6) ax.axis('off') # fig.savefig('../case_studies/basic_correction-src_ref_corr.jpg', dpi=92) ``` -------------------------------- ### homonim.RasterCompare.create_config Source: https://homonim.readthedocs.io/en/stable/_generated/homonim.RasterCompare.create_config.html Utility method to create a RasterCompare configuration dictionary whose items can be passed as keyword arguments to RasterCompare.process(). ```APIDOC ## homonim.RasterCompare.create_config(threads=0, max_block_mem=512, downsampling=Resampling.average, upsampling=Resampling.cubic_spline) ### Description Utility method to create a RasterCompare configuration dictionary whose items can be passed as keyword arguments to `RasterCompare.process()`. Without arguments, the default configuration is returned. ### Parameters - **threads** (int, optional) - Number of image blocks to process concurrently. 0 = use all processors. - **max_block_mem** (float, optional) - Maximum size of an image block in megabytes. - **downsampling** (rasterio.enums.Resampling, optional) - Resampling method to use when downsampling. - **upsampling** (rasterio.enums.Resampling, optional) - Resampling method to use when upsampling. ### Returns - **dict** - Configuration dictionary. ``` -------------------------------- ### homonim.RasterFuse.create_out_profile Source: https://homonim.readthedocs.io/en/stable/_generated/homonim.RasterFuse.create_out_profile.html Creates a profile dictionary for output images, defining format, data type, nodata values, and driver-specific creation options. ```APIDOC ## homonim.RasterFuse.create_out_profile ### Description Utility method to create a profile for the output image(s) that can be passed to `RasterFuse.process()`. Without arguments, the default profile is returned. ### Parameters - **driver** (str) - Optional - Output format driver. See the GDAL docs for available options. Default: 'GTiff'. - **dtype** (str) - Optional - Output image data type. One of: uint8|uint16|int16|uint32|int32|float32|float64. Default: 'float32'. - **nodata** (float) - Optional - Output image nodata value. If set to None, an internal mask is written. - **creation_options** (Dict) - Optional - Driver specific creation options e.g. dict(compress='deflate'). ### Returns - **dict** - Output image profile. ``` -------------------------------- ### RasterFuse.__init__ Source: https://homonim.readthedocs.io/en/stable/api.html Initializes the RasterFuse class for correcting an image to surface reflectance by fusion with a reference. ```APIDOC ## RasterFuse.__init__(src_filename, ref_filename, proc_crs=None, src_bands=None, ref_bands=None, force=False) ### Description Initializes the RasterFuse object. For best results, reference and source images should be concurrent, co-located, and spectrally similar. ### Parameters - **src_filename** (str/Path) - Required - Path to a source image file. - **ref_filename** (str/Path) - Required - Path to a reference image file. - **proc_crs** (homonim.enums.ProcCrs) - Optional - Specifies which of the source/reference image CRS and pixel grid to use. - **src_bands** (list of int) - Optional - Indexes of source spectral bands to be processed (1-based). - **ref_bands** (list of int) - Optional - Indexes of reference spectral bands to match and fuse with source bands (1-based). - **force** (bool) - Optional - Bypass auto wavelength matching and band-matching errors. ```