--- license: cc-by-4.0 ---
# SEN2NAIP The increasing demand for high spatial resolution in remote sensing imagery has led to the necessity of super-resolution (SR) algorithms that convert low-resolution (LR) images into high-resolution (HR) ones. To address this need, we introduce SEN2NAIP, a large remote sensing dataset designed to support conventional and reference-based SR model training. SEN2NAIP is structured into two components to provide a broad spectrum of research and application needs. The first component comprises a cross-sensor dataset of 2,851 pairs of LR images from Sentinel-2 L2A and HR images from the National Agriculture Imagery Program (NAIP). Leveraging this dataset, we developed a degradation model capable of converting NAIP images to match the characteristics of Sentinel-2 imagery ($S2_{like}$). Subsequently, this degradation model was utilized to create the second component, a synthetic dataset comprising 17,657 NAIP and $S2_{like}$ image pairs. With the SEN2NAIP dataset, we aim to provide a valuable resource that facilitates the exploration of new techniques for enhancing the spatial resolution of Sentinel-2 satellite imagery. ## Load cross-sensor dataset ```{python} import rioxarray import torch DEMO_PATH = "https://huggingface.co/datasets/isp-uv-es/SEN2NAIP/resolve/main/demo/" cross_sensor_path = DEMO_PATH + "cross-sensor/ROI_0000/" hr_data = rioxarray.open_rasterio(cross_sensor_path + "hr.tif") lr_data = rioxarray.open_rasterio(cross_sensor_path + "lr.tif") hr_torch = torch.from_numpy(hr_data.to_numpy()) / 255 lr_torch = torch.from_numpy(lr_data.to_numpy()) / 10000 ``` ## Load Synthetic dataset ```{python} import opensr_degradation import rioxarray import datasets import requests import tempfile import torch import json def load_metadata(metadata_path: str) -> dict: tmpfile = tempfile.NamedTemporaryFile(suffix=".json") with requests.get(metadata_path) as response: with open(tmpfile.name, "wb") as file: file.write(response.content) metadata_json = json.load(open(tmpfile.name, "r")) return metadata_json DEMO_PATH = "https://huggingface.co/datasets/isp-uv-es/SEN2NAIP/resolve/main/demo/" # Synthetic LR and HR data ------------------------------ synthetic_path = DEMO_PATH + "synthetic/ROI_0001/" hr_early_data = rioxarray.open_rasterio(synthetic_path + "early/01__m_4506807_nw_19_1_20110818.tif") hr_early_torch = torch.from_numpy(hr_early_data.to_numpy()) / 255 hr_early_metadata = load_metadata(synthetic_path + "late/metadata.json") hr_early_torch_hat = opensr_degradation.main.predict_table( hr_early_torch, hr_early_metadata["sim_histograms"], "gamma_multivariate_normal_50" ) hr_late_data = rioxarray.open_rasterio(synthetic_path + "late/02__m_4506807_nw_19_060_20210920.tif") hr_late_torch = torch.from_numpy(hr_late_data.to_numpy()) / 255 hr_late_metadata = load_metadata(synthetic_path + "late/metadata.json") hr_late_torch_hat = opensr_degradation.main.predict_table( hr_late_torch, hr_late_metadata["sim_histograms"], "gamma_multivariate_normal_50" ) import matplotlib.pyplot as plt fig, ax = plt.subplots(2, 2, figsize=(10, 5)) ax = ax.flatten() ax[0].imshow(hr_early_torch[[3, 1, 2]].permute(1, 2, 0)) ax[0].set_title("Original") ax[1].imshow(hr_early_torch_hat[[3, 1, 2]].permute(1, 2, 0)*3) ax[1].set_title("Degraded") ax[2].imshow(hr_late_torch[[3, 1, 2]].permute(1, 2, 0)) ax[2].set_title("Original") ax[3].imshow(hr_late_torch_hat[[3, 1, 2]].permute(1, 2, 0)*3) ax[3].set_title("Degraded") # remove axis and space for a in ax: a.axis("off") plt.tight_layout() plt.show() ```