Atmospheric Correction with Acolite¶
Acolite can perform atmospheric correction on a variety of satellite sensors, including Landsat, Sentinel-2, PACE, EMIT, AVIRIS, among others. For more information on how to use Acolite, please refer to the Acolite manual
In this example, we will use Acolite to perform atmospheric correction on a Sentinel-2 image.
In [ ]:
Copied!
# %pip install "hypercoast[extra]"
# %pip install "hypercoast[extra]"
Import libraries¶
In [ ]:
Copied!
import os
import hypercoast
import os
import hypercoast
Download sample data¶
In [ ]:
Copied!
url = "https://github.com/opengeos/datasets/releases/download/hypercoast/S2A_MSIL1C_20160920T164452_N0204_R083_T15RYN_20160920T164450.SAFE.zip"
work_dir = os.path.expanduser("~/Downloads")
filepath = os.path.join(work_dir, os.path.basename(url))
hypercoast.download_file(url, filepath, quiet=True)
url = "https://github.com/opengeos/datasets/releases/download/hypercoast/S2A_MSIL1C_20160920T164452_N0204_R083_T15RYN_20160920T164450.SAFE.zip"
work_dir = os.path.expanduser("~/Downloads")
filepath = os.path.join(work_dir, os.path.basename(url))
hypercoast.download_file(url, filepath, quiet=True)
In [ ]:
Copied!
input_dir = filepath.replace(".zip", "")
if not os.path.exists(input_dir):
raise FileNotFoundError(f"Directory {input_dir} not found")
input_dir = filepath.replace(".zip", "")
if not os.path.exists(input_dir):
raise FileNotFoundError(f"Directory {input_dir} not found")
Download Acolite software¶
In [ ]:
Copied!
acolite_dir = hypercoast.download_acolite(work_dir)
print(f"Acolite directory: {acolite_dir}")
acolite_dir = hypercoast.download_acolite(work_dir)
print(f"Acolite directory: {acolite_dir}")
Run Acolite¶
In [ ]:
Copied!
out_dir = os.path.join(work_dir, "output")
out_dir = os.path.join(work_dir, "output")
In [ ]:
Copied!
hypercoast.run_acolite(
acolite_dir=acolite_dir,
input_file=input_dir,
out_dir=out_dir,
l2w_parameters="Rrs_*,chl_oc3,chl_re_mishra,spm_nechad2016",
rgb_rhot=True,
rgb_rhos=False,
map_l2w=True,
)
hypercoast.run_acolite(
acolite_dir=acolite_dir,
input_file=input_dir,
out_dir=out_dir,
l2w_parameters="Rrs_*,chl_oc3,chl_re_mishra,spm_nechad2016",
rgb_rhot=True,
rgb_rhos=False,
map_l2w=True,
)
Batch processing¶
To process multiple images, put all the images in a folder. For example, unzip all the images in the data
folder. Then, run the following code to make sure that all image folders are listed.
In [ ]:
Copied!
input_dir = os.path.join(work_dir, "data")
input_files = [os.path.join(input_dir, f) for f in os.listdir(input_dir)]
input_files
input_dir = os.path.join(work_dir, "data")
input_files = [os.path.join(input_dir, f) for f in os.listdir(input_dir)]
input_files
Run the following code to process all images in the data
folder.
In [ ]:
Copied!
hypercoast.run_acolite(
acolite_dir=acolite_dir,
input_file=input_files,
out_dir=out_dir,
l2w_parameters="Rrs_*,chl_oc3,chl_re_mishra,spm_nechad2016",
rgb_rhot=True,
rgb_rhos=False,
map_l2w=True,
)
hypercoast.run_acolite(
acolite_dir=acolite_dir,
input_file=input_files,
out_dir=out_dir,
l2w_parameters="Rrs_*,chl_oc3,chl_re_mishra,spm_nechad2016",
rgb_rhot=True,
rgb_rhos=False,
map_l2w=True,
)