Geocode Sentinel-1 SLC products¶
In [ ]:
Copied!
%load_ext autoreload
%autoreload 2
import logging
logging.basicConfig(level=logging.INFO)
import matplotlib.pyplot as plt
import geopandas as gpd
from eodag import EODataAccessGateway
import rioxarray as riox
from eo_tools.S1.process import process_slc
# credentials need to be stored in the following file (see EODAG docs)
confpath = "/data/eodag_config.yml"
dag = EODataAccessGateway(user_conf_file_path=confpath)
# make sure cop_dataspace will be used
dag.set_preferred_provider("cop_dataspace")
logging.basicConfig(level=logging.INFO)
%load_ext autoreload
%autoreload 2
import logging
logging.basicConfig(level=logging.INFO)
import matplotlib.pyplot as plt
import geopandas as gpd
from eodag import EODataAccessGateway
import rioxarray as riox
from eo_tools.S1.process import process_slc
# credentials need to be stored in the following file (see EODAG docs)
confpath = "/data/eodag_config.yml"
dag = EODataAccessGateway(user_conf_file_path=confpath)
# make sure cop_dataspace will be used
dag.set_preferred_provider("cop_dataspace")
logging.basicConfig(level=logging.INFO)
Set up parameters and output dir¶
In [2]:
Copied!
# change to your custom locations
data_dir = "/data/S1"
ids = [
"S1A_IW_SLC__1SDV_20230904T063730_20230904T063757_050174_0609E3_DAA1",
]
slc_path = f"{data_dir}/{ids[0]}.zip"
output_dir="/data/res/test-slc-processor"
# change to your custom locations
data_dir = "/data/S1"
ids = [
"S1A_IW_SLC__1SDV_20230904T063730_20230904T063757_050174_0609E3_DAA1",
]
slc_path = f"{data_dir}/{ids[0]}.zip"
output_dir="/data/res/test-slc-processor"
Download S-1 products¶
In [ ]:
Copied!
# load a geometry
aoi_file = "https://raw.githubusercontent.com/odhondt/eo_tools/refs/heads/main/data/Morocco_AOI.geojson"
shp = gpd.read_file(aoi_file).geometry[0]
search_criteria = {
"productType": "S1_SAR_SLC",
"start": "2023-09-03",
"end": "2023-09-17",
"geom": shp
}
results = dag.search(**search_criteria)
to_dl = [it for it in results if it.properties["id"] in ids]
print(f"{len(to_dl)} products to download")
dag.download_all(to_dl, output_dir="/data/S1/", extract=False)
# load a geometry
aoi_file = "https://raw.githubusercontent.com/odhondt/eo_tools/refs/heads/main/data/Morocco_AOI.geojson"
shp = gpd.read_file(aoi_file).geometry[0]
search_criteria = {
"productType": "S1_SAR_SLC",
"start": "2023-09-03",
"end": "2023-09-17",
"geom": shp
}
results = dag.search(**search_criteria)
to_dl = [it for it in results if it.properties["id"] in ids]
print(f"{len(to_dl)} products to download")
dag.download_all(to_dl, output_dir="/data/S1/", extract=False)
Apply pre-processing and geocode SLC amplitude¶
In [ ]:
Copied!
out_dir = process_slc(
slc_path=slc_path,
output_dir=output_dir,
aoi_name=None,
shp=shp,
pol="vv",
subswaths=["IW1", "IW2", "IW3"],
dem_upsampling=1.8,
dem_force_download=False,
dem_buffer_arc_sec=40,
multilook=[1, 4],
warp_kernel="bicubic",
cal_type="sigma",
clip_to_shape=True,
)
out_dir = process_slc(
slc_path=slc_path,
output_dir=output_dir,
aoi_name=None,
shp=shp,
pol="vv",
subswaths=["IW1", "IW2", "IW3"],
dem_upsampling=1.8,
dem_force_download=False,
dem_buffer_arc_sec=40,
multilook=[1, 4],
warp_kernel="bicubic",
cal_type="sigma",
clip_to_shape=True,
)
Visualize¶
In [3]:
Copied!
arr = riox.open_rasterio(f"{out_dir}/amp_vv.tif")[0]
arr.plot.imshow(vmin=0, vmax=1, cmap="gray")
arr = riox.open_rasterio(f"{out_dir}/amp_vv.tif")[0]
arr.plot.imshow(vmin=0, vmax=1, cmap="gray")
Out[3]:
<matplotlib.image.AxesImage at 0x7fe53345eff0>