Skip to content
GitLab
    • Explore Projects Groups Topics Snippets
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • scenes scenes
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Graph
    • Compare revisions
  • Issues 9
    • Issues 9
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Incidents
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

La forge institutionnelle d'INRAE étant en production depuis le 10 juin 2025, nous vous invitons à y créer vos nouveaux projets.

  • umr-tetisumr-tetis
  • scenesscenes
  • Merge requests
  • !25

Resolve "Update drs_search"

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged Cresson Remi requested to merge 9-search into develop 3 years ago
  • Overview 0
  • Commits 3
  • Pipelines 2
  • Changes 6

Closes #9 (closed)

Compare
  • version 1
    b591214a
    3 years ago

  • develop (base)

and
  • latest version
    ac81d258
    3 commits, 3 years ago

  • version 1
    b591214a
    2 commits, 3 years ago

6 files
+ 44
− 48

    Preferences

    File browser
    Compare changes
test/drs_import.py → apps/drs_spot67_import.py
+ 2
− 1
  • View file @ ac81d258

  • Edit in single-file editor

  • Open in Web IDE


@@ -3,8 +3,9 @@ from scenes import save_scenes
@@ -3,8 +3,9 @@ from scenes import save_scenes
from scenes.spot import get_spot67_scenes
from scenes.spot import get_spot67_scenes
# Arguments
# Arguments
parser = argparse.ArgumentParser(description="Test",)
parser = argparse.ArgumentParser(description="Import Spot-6/7 images from DRS into a list of scenes (pickle)",)
parser.add_argument("--root_dirs", nargs='+', help="Root directories containing MS and PAN folders", required=True)
parser.add_argument("--root_dirs", nargs='+', help="Root directories containing MS and PAN folders", required=True)
 
parser.add_argument("--tile_name", help="Filter only images from this tile (optional)")
parser.add_argument("--out_pickle", help="Output pickle file", required=True)
parser.add_argument("--out_pickle", help="Output pickle file", required=True)
params = parser.parse_args()
params = parser.parse_args()
test/s2_import.py → apps/s2_import.py
+ 16
− 0
  • View file @ ac81d258

  • Edit in single-file editor

  • Open in Web IDE

import argparse
import argparse
from scenes import utils, sentinel, save_scenes
from scenes import save_scenes
 
from scenes.sentinel import get_local_scenes
# Arguments
# Arguments
parser = argparse.ArgumentParser(description="Test",)
parser = argparse.ArgumentParser(description="Test",)
parser.add_argument("--root_dirs", nargs='+', help="Root directories containing S2 archives (.zip)", required=True)
parser.add_argument("--root_dirs", nargs='+', help="Root directories containing S2 archives (.zip)", required=True)
parser.add_argument("--out_pickle", help="Output pickle file", required=True)
parser.add_argument("--out_pickle", help="Output pickle file", required=True)
parser.add_argument('--level', default='2A', const='2A', nargs='?', choices=['2A', '3A'], help='Product level')
parser.add_argument("--tile_name", help="(Optional) Tile name")
params = parser.parse_args()
params = parser.parse_args()
# Get all scenes in the root_dir
# Search all Sentinel-2 scenes
product_type = sentinel.Sentinel23AScene if params.level == '2A' else sentinel.Sentinel23AScene
s2_scenes = [get_local_scenes(root_dir=root_dir, tile=params.tile_name) for root_dir in params.root_dirs]
archives = []
for root_dir in params.root_dirs:
archives += utils.find_files_in_all_subdirs(pth=root_dir, pattern="*.zip", case_sensitive=False)
scenes = [product_type(archive=archive) for archive in archives]
# Save scenes in a pickle file
# Save scenes in a pickle file
save_scenes(scenes, params.out_pickle)
save_scenes(s2_scenes, params.out_pickle)
test/drs_search.py → apps/search.py
+ 25
− 0
  • View file @ ac81d258

  • Edit in single-file editor

  • Open in Web IDE

import argparse
import argparse
from scenes import utils, Index
from scenes import load_scenes, Index, utils
# Arguments
# Arguments
parser = argparse.ArgumentParser(description="Test",)
parser = argparse.ArgumentParser(description="Search scenes intesecting an ROI",)
parser.add_argument("--root_dir", help="Root directory containing MS and PAN folders", required=True)
parser.add_argument("--pickle_file", help="List of scenes (serialized in pickle format)", required=True)
parser.add_argument("--roi", required=True)
parser.add_argument("--roi", help="ROI. Can be a vector or a raster", required=True)
params = parser.parse_args()
params = parser.parse_args()
# Find pairs of DIMAPS
# Load scenes list
scenes = drs.get_spot67_scenes(params.root_dir)
scenes = load_scenes(params.pickle_file)
# spatial index
# spatial index
print("Indexation...")
print("Indexation...")
idx = Index(scenes)
idx = Index(scenes)
# search
# search
print("search roi")
print("Search roi")
bbox_fn = utils.get_bbox_wgs84_from_raster if params.roi.lower().endswith(".tif") \
bbox_fn = utils.get_bbox_wgs84_from_raster if params.roi.lower().endswith(".tif") \
else utils.get_bbox_wgs84_from_vector
else utils.get_bbox_wgs84_from_vector
matches = idx.find(bbox_wgs84=bbox_fn(params.roi))
matches = idx.find(bbox_wgs84=bbox_fn(params.roi))
print("{} scenes found.".format(len(matches)))
print(f"{len(matches)} scenes found.")
#for scene_match in matches:
for i, scene_match in enumerate(matches):
# print(scene_match)
print(f"Scene #{i}")
 
print(scene_match)
scenes/sentinel.py
+ 1
− 1
  • View file @ ac81d258

  • Edit in single-file editor

  • Open in Web IDE


@@ -317,7 +317,7 @@ class Sentinel23AScene(Sentinel2SceneBase):
@@ -317,7 +317,7 @@ class Sentinel23AScene(Sentinel2SceneBase):
def get_scene(archive):
def get_scene(archive):
"""
"""
Return the right sentinel scene instance from the givent archive (L2A or L3A)
Return the right sentinel scene instance from the given archive (L2A or L3A)
Args:
Args:
archive: L3A or L3A archive
archive: L3A or L3A archive
test/drs_stack.py deleted 100644 → 0
+ 0
− 34
  • View file @ b1ef5e51

import argparse
import pyotb
from scenes import utils, Index
from scenes.spot import get_spot67_scenes
# Arguments
parser = argparse.ArgumentParser(description="Test",)
parser.add_argument("--root_dir", help="Root directory containing MS and PAN folders", required=True)
parser.add_argument("--roi", required=True)
parser.add_argument("--out", required=True)
params = parser.parse_args()
# Find pairs of DIMAPS
scenes = get_spot67_scenes(params.root_dir)
# spatial index
print("Indexation...")
idx = Index(scenes)
# search
print("search roi")
bbox = utils.get_bbox_wgs84_from_raster(params.roi)
matches = idx.find(bbox_wgs84=bbox)
print("{} scenes found.".format(len(matches)))
# sort
print("sort")
sources_list = [sc.get_imagery().get_xs().resample_over(ref_img=params.roi) for sc in matches]
sources_list.sort(key=lambda src: src.root_imagery.root_scene.acquisition_date)
# stack
print("concatenation")
concat = pyotb.ConcatenateImages({"il": sources_list})
concat.write(params.out)
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
1
Bug
1
Bug
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 Participant
Cresson Remi
Reference: umr-tetis/scenes!25
Source branch: 9-search

Menu

Explore Projects Groups Topics Snippets