Giter Site home page Giter Site logo

saifaati / geospatial-cosicorr3d Goto Github PK

View Code? Open in Web Editor NEW
51.0 7.0 15.0 570.3 MB

Tools and libraries for processing satellite images (push-broom, frame and push-frame), including rigorous sensor model (RSM) refinement, rational function model (RFM) refinement, orthorectification, sub-pixel image correlation, and 3D surface displacement extraction.

License: Other

Dockerfile 0.09% Python 99.25% Shell 0.66%
remote-sensing satellite-imagery orthorectification earth-observation glacier landslide earth-surface-displacement 3d-displacement image-correlation

geospatial-cosicorr3d's Introduction

Copyright 2021 Saif Aati ([email protected] || [email protected])

Linux-Conda-Install (CI- GHA) Linux-Docker-install (CI- GHA) Correlation-conda (CI-GHA) Ortho-conda (CI-GHA)

geoCosiCorr3D

geoCosiCorr3D is an innovative, free and open-source software tailored for satellite image processing. geoCosiCorr3D is adept at handling various types of satellite imagery, including push-broom, frame, and push-frame sensors. At its core, geoCoiCorr3D excels in rigorous sensor model (RSM) refinement, rational function model (RFM) refinement, and offers advanced processing features: including orthorectification, sub-pixel image correlation, and 3D surface displacement extraction.

Designed for researchers in remote sensing. geoCosiCorr3D serves as a critical bridge linking complex data processing requirements with real-world applicability. It is particularly beneficial for projects focused on change detection, time series analysis, and applications in diverse scientific fields such as geology, geomorphology, glaciology, planetology, as well as in the assessment and mitigation of natural disasters.

See the NEWS for the most recent additions and upgrades.

Contact Information, Support & Contributions

We welcome your questions, comments, and reports of any issues you encounter! Here's how you can reach out to us or contribute to the project. For direct inquiries or specific questions, feel free to reach out to Saif Aati: ( [email protected] (Preferred) || [email protected])

If you encounter any problems or bugs, please report them by submitting an issue on our GitHub project page. This helps us track and address issues efficiently. Your feedback and contributions are invaluable to us, and we look forward to hearing from you!

Workflow

Alt text

Installation

There are two methods available to install geoCosiCorr3D: using Conda or Docker. Follow the instructions below based on your preferred installation method.

Option 1: Installing with Conda

  1. To install using Conda, execute the following script in your terminal:
    ./install_cosicorr.sh --conda
    If Conda (or Miniconda) is not already installed on your machine, the script will attempt to install Miniconda automatically.
  2. Once the installation is complete, you can activate the geoCosiCorr3D environment with:
    conda activate geoCosiCorr3D
    Alternatively, you can run Python scripts within the environment without activating it by using:
    conda run -n geoCosiCorr3D your_script.py
    Replace your_script.py with the name of the Python script you wish to run.

Option 2: Installing with Docker

For Docker installation, execute the following command:

./install_cosicorr.sh --docker

This command will attempt to install Docker if it's not already installed on your system, start the Docker service, and then pull the base geoCosiCorr3D Docker image. Ensure you have the necessary permissions to install software on your system when using this option.


Note: Please follow these steps for a smooth installation process. If you encounter any issues or need further assistance, refer to the documentation (the documentation is still under construction 🚧) or submit an issue on the project's GitHub page.

Important Note on Environment Variables

⚠️ Sometimes, environment variables are not automatically picked up and set during the installation process. To ensure the software operates correctly, it is recommended to manually set these variables. For example, to set the LD_LIBRARY_PATH environment variable, you can use the following command in your terminal:

export LD_LIBRARY_PATH=<absolute_path_of_installation_directory>/Geospatial-COSICorr3D/lib/:$LD_LIBRARY_PATH

Add this line to your .bashrc or .bash_profile (depending on your shell and OS) to make the change permanent:

echo 'export LD_LIBRARY_PATH=<absolute_path_of_installation_directory>/Geospatial-COSICorr3D/lib/:$LD_LIBRARY_PATH' >> ~/.bashrc

geoCosiCorr3D: CLI

The primary entry point for the geoCosiCorr3D command line interface (CLI) is accessible through the Python script located at scripts/cosicorr.py. To explore the available commands and their options, you can use the -h or --help flag. Below is a brief overview of how to use the GeoCosiCorr3D CLI:

python3 scripts/cosicorr.py -h
usage: cosicorr3d [-h] <module> ...

GeoCosiCorr3D CLI

optional arguments:
  -h, --help  show this help message and exit

modules:
  <module>
    ortho      Orthorectification
    transform  Transformation
    correlate  Correlation

Correlation

For detailed usage of the correlate module, execute the following command:

python3 scripts/cosicorr.py correlate -h
Correlate Module Usage
usage: cosicorr3d correlate [-h] [--base_band BASE_BAND] [--target_band TARGET_BAND] [--output_path OUTPUT_PATH] [--method {frequency,spatial}] [--window_size WINDOW_SIZE WINDOW_SIZE WINDOW_SIZE WINDOW_SIZE]
                            [--step STEP STEP] [--grid] [--show] [--pixel_based] [--vmin VMIN] [--vmax VMAX] [--mask_th MASK_TH] [--nb_iters NB_ITERS] [--search_range SEARCH_RANGE SEARCH_RANGE]
                            base_image target_image

positional arguments:
  base_image            Path to the base image.
  target_image          Path to the target image.

optional arguments:
  -h, --help            show this help message and exit
  --base_band BASE_BAND
                        Base image band.
  --target_band TARGET_BAND
                        Target image band.
  --output_path OUTPUT_PATH
                        Output correlation path.
  --method {frequency,spatial}
                        Correlation method to use.
  --window_size WINDOW_SIZE WINDOW_SIZE WINDOW_SIZE WINDOW_SIZE
                        Window size. (Default [64])
  --step STEP STEP      Step size. (Default [8,8])
  --grid                Use grid.
  --show                Show correlation. (Default False)
  --pixel_based         Enable pixel-based correlation.
  --vmin VMIN           Minimum value for correlation plot. (Default -1)
  --vmax VMAX           Maximum value for correlation plot. (Default 1)

Frequency method arguments:
  --mask_th MASK_TH     Mask threshold (only for frequency method).
  --nb_iters NB_ITERS   Number of iterations (only for frequency method).

Spatial method arguments:
  --search_range SEARCH_RANGE SEARCH_RANGE
                        Search range (only for spatial method).

Example:

python3 scripts/cosicorr.py correlate tests/test_dataset/BASE_IMG.TIF tests/test_dataset/TARGET_IMG.TIF --show  --vmin -3 --vmax 3

Alt text

Transform

For detailed usage of the transfrom module, execute the following command:

python3 scripts/cosicorr.py transform -h
Transform Module Usage

Example Usage of the transform Command:

This section demonstrates how to use the transform command within the geoCosiCorr3D CLI to perform coordinate transformations. The examples show how to convert pixel coordinates to geographic coordinates (longitude, latitude, and altitude) and vice versa.

usage: cosicorr3d transform [-h] [--inv] [--dem_fn DEM_FN] x y <model_name> ...

positional arguments:
  x                list: x=cols and if with invert flag: lon
  y                list: y=lines and if with invert flag: lat

optional arguments:
  -h, --help       show this help message and exit
  --inv            Transform form ground to image space.
  --dem_fn DEM_FN  DEM file name (None)

model:
  <model_name>
    RFM            RFM model specific arguments
    RSM            RSM model specific arguments

Converting Pixel Coordinates to Geographic Coordinates

To convert pixel coordinates to geographic coordinates using a Rational Function Model (RFM), use the following command:

python3 scripts/cosicorr.py transform 0,1000 0,500 RFM tests/test_dataset/test_ortho_dataset/SP2_RPC.txt

Output:

  • lons: [30.52895296 30.65688292]
  • lat: [41.24090926 41.16826844]
  • alt: [1102.49239388 1102.49239388]

Inverse Transformation: Converting Geographic Coordinates to Pixel Coordinates

For the inverse operation: converting geographic coordinates back to pixel coordinates, use the --inv flag:

python3 scripts/cosicorr.py transform 30.52895296,30.65688292 41.24090926,41.16826844 --inv RFM tests/test_dataset/test_ortho_dataset/SP2_RPC.txt

Output:

  • cols: [9.70195697e-06 999.999998e+02]
  • lines: [5.07104141e-06 500.000045e+02]

Orthorectification and model refinement

For detailed usage of the ortho module, execute the following command:

python3 scripts/cosicorr.py ortho -h
Ortho Module Usage
usage: cosicorr3d ortho [-h] [--o_ortho O_ORTHO] [--corr_model CORR_MODEL] [--dem DEM] [--gsd GSD] [--resampling_method {sinc,bilinear}] [--debug] [--show] [--refine]
                        [--ref_img REF_IMG] [--gcps GCPS]
                        input_img <model_name> ...

positional arguments:
  input_img             Input file for ortho

optional arguments:
  -h, --help            show this help message and exit
  --o_ortho O_ORTHO     Output path for ortho. Defaults to the current working directory.
  --corr_model CORR_MODEL
                        Correction model path (None)
  --dem DEM             DEM path (None)
  --gsd GSD             Output file for ortho (None)
  --resampling_method {sinc,bilinear}
                        Resampling method (SINC)
  --debug
  --show
  --refine              Refine model, this require GCPs or reference imagery to collect GCPs
  --ref_img REF_IMG     Reference Ortho image (None)
  --gcps GCPS           GCPs file (None)

model:
  <model_name>
    RFM                 RFM model specific arguments
    RSM                 RSM model specific arguments
RSM model
usage: cosicorr3d ortho input_img RSM [-h] {Spot1,Spot2,Spot3,Spot4,Spot5,Spot15,Spot6,Spot7,Spot67,WV1,WV2,WV3,WV4,GE,QB,DG} rsm_fn

positional arguments:
  {Spot1,Spot2,Spot3,Spot4,Spot5,Spot15,Spot6,Spot7,Spot67,WV1,WV2,WV3,WV4,GE,QB,DG}
                        Sat-name
  rsm_fn                Specifies the path to the .xml DMP file. Additional formats are supported in GeoCosiCorr3D.pro.
RFM model
usage: cosicorr3d ortho input_img RFM [-h] rfm_fn

positional arguments:
  rfm_fn      RFM file name (.tiff or .TXT)
Upcoming Release Information
  • Scheduled Release Date: May 2024
  • Features to be Included:
    • ortho Module
    • RSM Transformation module

geoCosiCorr3D: GUI

License

License

Citation

If you are using this software for academic research or publications we ask that you please cite this software as:

[1] Aati, S., Milliner, C., Avouac, J.-P., 2022. A new approach for 2-D and 3-D precise measurements of ground deformation from optimized registration and correlation of optical images and ICA-based filtering of image geometry artifacts. Remote Sensing of Environment 277, 113038. https://doi.org/10.1016/j.rse.2022.113038

References

[2] S. Leprince, S. Barbot, F. Ayoub and J. Avouac, "Automatic and Precise Orthorectification, Coregistration, and Subpixel Correlation of Satellite Images, Application to Ground Deformation Measurements," in IEEE Transactions on Geoscience and Remote Sensing, vol. 45, no. 6, pp. 1529-1558, June 2007, doi: 10.1109/TGRS.2006.888937.

[3] Aati, S.; Avouac, J.-P. Optimization of Optical Image Geometric Modeling, Application to Topography Extraction and Topographic Change Measurements Using PlanetScope and SkySat Imagery. Remote Sens. 2020, 12,

  1. https://doi.org/10.3390/rs12203418

geospatial-cosicorr3d's People

Contributors

saifaati avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

geospatial-cosicorr3d's Issues

OSError: libsvml.so: cannot open shared object file: No such file or directory

Hi,

I've been following the steps to install the Geospatial-COSICorr3D. After creating properly the conda environment, and adding the lines in the .bashrc file, try to run a simple correlation :

correlation = Correlate(base_image_path=img1,
target_image_path=img2,
base_band=1,
target_band=1,
output_corr_path=indir,
corr_config=corr_config,
corr_show=False)

But I get this error :

Correlation per tile: 0%| | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/home/montagtr/Geospatial-COSICorr3D/geoCosiCorr3D/geoCore/core_correlation.py", line 107, in run_correlator
lib_cfreq_corr = cdll.LoadLibrary(FREQ_CORR_LIB)
File "/home/montagtr/anaconda3/envs/geoCosiCorr3D/lib/python3.7/ctypes/init.py", line 442, in LoadLibrary
return self._dlltype(name)
File "/home/montagtr/anaconda3/envs/geoCosiCorr3D/lib/python3.7/ctypes/init.py", line 364, in init
self._handle = _dlopen(self._name, mode)
OSError: libsvml.so: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/montagtr/PhD/phd-sandbox/sandbox.py", line 42, in
corr_show=False)
File "/home/montagtr/Geospatial-COSICorr3D/geoCosiCorr3D/geoImageCorrelation/correlate.py", line 48, in init
self.run_correlation()
File "/home/montagtr/Geospatial-COSICorr3D/geoCosiCorr3D/geoImageCorrelation/correlate.py", line 155, in run_correlation
ew_array, ns_array, snr_array = self.run_corr_engine(base_subset, target_subset)
File "/home/montagtr/Geospatial-COSICorr3D/geoCosiCorr3D/geoImageCorrelation/correlate.py", line 192, in run_corr_engine
mask_th=self.corr_engine.corr_params.mask_th)
File "/home/montagtr/Geospatial-COSICorr3D/geoCosiCorr3D/geoCore/core_correlation.py", line 109, in run_correlator
raise InvalidCorrLib
geoCosiCorr3D.geoCore.core_correlation.InvalidCorrLib

Do you have any idea where this could come from?

Thanks for you help !

Tristan.

UTM to Geo

How to get accurate geographical coordinate systems from the TIF file? I turned through GDAL, but there was a bit offset in the border. Is there any convenient command line to transform?

Image Correlation Error

Hello, using a rectangular window in the image correlation process, the result is the following error ' Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)', while the square correlation window is running correctly. Why is this happening?
1670672459(1)

CosiCorr libraries are not being accessed in anaconda environment

For linux, instead of adding the following to the .bashrc file:

LD_LIBRARY_PATH=~/geoCosiCorr3D/lib/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

You will have to add instead

LD_LIBRARY_PATH=~/Geospatial-COSICorr3D/geoCosiCorr3D /lib/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

This fixed the issue for me given that I did clone the CosiCorr3D repository to the home directory (cd ~).

GCP optimization - UTM zone ValueError

I am trying to run the full orthorectification workflow on a single SPOT 5 HRG scene, using a Pléiades orthorectified scene + DEM as reference.
When I call cGCPOptimization(), I get the attached error message. For some reason, there is also a warning "UserWarning: Reproject DEM from 32642-->32641", but the entire domain lies well within the EPSG:32642 region.

gcpOptimization_errorMessage.txt

ValueError while orthorectification SPOT 6 imagery

I'm facing this issue while using geoCosiCorr3D orthorectification module for Spot 6 imagery using RSM

python3 ~/tools/Geospatial-COSICorr3D/scripts/cosicorr.py ortho IMG_SPOT6_P_202102010658122_SEN_PRODUCTION_20231115_061218_1.TIF --o_ortho ./R --gsd 6 --dem output_COP30.tif --debug RSM Spot6 DIM_SPOT6_P_202102010658122_SEN_PRODUCTION_20231115_061218_1.XML 
2024-05-19 11:16:28,092 [INFO] sat_model:SatModelParams(SAT_MODEL='RSM', METADATA='DIM_SPOT6_P_202102010658122_SEN_PRODUCTION_20231115_061218_1.XML', SENSOR='Spot6')
2024-05-19 11:16:36,370 [INFO] Input RSM sensor: Spot6
2024-05-19 11:16:36,370 [INFO] Satellite sensor:Spot6
2024-05-19 11:16:36,372 [INFO] DIM_SPOT6_P_202102010658122_SEN_PRODUCTION_20231115_061218_1.XML
2024-05-19 11:16:36,376 [INFO] ['Metadata_Identification', 'Dataset_Identification', 'Dataset_Content', 'Product_Information', 'Coordinate_Reference_System', 'Geoposition', 'Processing_Information', 'Raster_Data', 'Radiometric_Data', 'Geometric_Data', 'Quality_Assessment', 'Dataset_Sources']
2024-05-19 11:16:36,377 [INFO] mission:SPOT,instrument:6,imagingDate:2021-02-01, imagingTime:06:58:12.2,
2024-05-19 11:16:36,378 [INFO] sunAz:142.773,sunElev:38.7923, meanGSD:2.14588, time:2021-02-01T06:58:12.806000Z, satAlt:7.00471e+05, azAngle:177.708, viewAngle:2.90017, incidenceAngle:3.36472
2024-05-19 11:16:36,379 [INFO] nbCols:38609,nbRows:72849,nbBands:1
2024-05-19 11:16:36,379 [INFO] --- Get Spot Sensor Configuration ---
2024-05-19 11:16:36,380 [INFO] linePeriod:0.000229110269,startTime:2243314692.789776,endTimeLine:2243314709.48
2024-05-19 11:16:36,380 [INFO] focal[m]:3.760, detectorSize[m]:(col:8.337,row:8.337)
2024-05-19 11:16:36,381 [INFO] --- Get Look angles ----
2024-05-19 11:16:36,382 [INFO] Look_Angles:
[[-4.27997145e-02]
 [ 2.21714038e-06]
 [ 0.00000000e+00]
 [ 0.00000000e+00]]
2024-05-19 11:16:36,394 [INFO] --- Computing SPOT 6  RSM:
2024-05-19 11:16:36,394 [INFO]  *
Traceback (most recent call last):
  File "/home/iess/tools/Geospatial-COSICorr3D/scripts/cosicorr.py", line 236, in <module>
    cosicorr()
  File "/home/iess/tools/Geospatial-COSICorr3D/scripts/cosicorr.py", line 230, in cosicorr
    args.func(args)
  File "/home/iess/tools/Geospatial-COSICorr3D/scripts/cosicorr.py", line 64, in ortho_func
    orthorectify(args.input_img, o_ortho_path, ortho_params, None, args.dem, args.refine,
  File "/home/iess/tools/Geospatial-COSICorr3D/geoCosiCorr3D/geoOrthoResampling/geoOrtho.py", line 607, in orthorectify
    ortho()
  File "/home/iess/tools/Geospatial-COSICorr3D/geoCosiCorr3D/geoOrthoResampling/geoOrtho.py", line 58, in __call__
    self.orthorectify()
  File "/home/iess/tools/Geospatial-COSICorr3D/geoCosiCorr3D/geoOrthoResampling/geoOrtho.py", line 61, in orthorectify
    self.model = self._get_rsm_model()
  File "/home/iess/tools/Geospatial-COSICorr3D/geoCosiCorr3D/geoOrthoResampling/geoOrtho.py", line 137, in _get_rsm_model
    return RSM.build_RSM(metadata_file=self.metadata, sensor_name=self.sensor, debug=self.debug)
  File "/home/iess/tools/Geospatial-COSICorr3D/geoCosiCorr3D/geoCore/core_RSM.py", line 52, in build_RSM
    rsm_sensor_model = cSpot67(dmpXml=metadata_file, debug=True)
  File "/home/iess/tools/Geospatial-COSICorr3D/geoCosiCorr3D/geoRSM/Spot_RSM.py", line 89, in __init__
    self.Interpolate_position_velocity_attitude()
  File "/home/iess/tools/Geospatial-COSICorr3D/geoCosiCorr3D/geoRSM/Spot_RSM.py", line 168, in Interpolate_position_velocity_attitude
    self.interpSatPosition[:, i] = f1(self.linesDate)
  File "/home/iess/miniconda3/envs/geoCosiCorr3D/lib/python3.9/site-packages/scipy/interpolate/_polyint.py", line 81, in __call__
    y = self._evaluate(x)
  File "/home/iess/miniconda3/envs/geoCosiCorr3D/lib/python3.9/site-packages/scipy/interpolate/_interpolate.py", line 766, in _evaluate
    below_bounds, above_bounds = self._check_bounds(x_new)
  File "/home/iess/miniconda3/envs/geoCosiCorr3D/lib/python3.9/site-packages/scipy/interpolate/_interpolate.py", line 799, in _check_bounds
    raise ValueError(f"A value ({above_bounds_value}) in x_new is above "
ValueError: A value (16.690224876111998) in x_new is above the interpolation range's maximum value (16.690224170684814).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.