This is a quick way of locating which scenes, from an archive of data, contain a point you are interested in.
First make a list of all available scenes
ls data/S1/2017/??/??/*/*vv*img > all_scenes.txt
Then use gdalbuildvrt to make a VRT file containing all scenes as a separate band (assumes scenes only have a single band).
gdalbuildvrt -input_file_list all_scenes.txt \ -separate -o s1_all_scenes.vrt
Use gdallocation info with ‘-lifonly’ flag to the scene the point we are interested in (1.5 N, 103 E) is within and redirect to a text file.
gdallocationinfo -lifonly -wgs84 s1_all_scenes.vrt \ 103 1.5 > selected_scenes.txt
This will show if within the bounding box of the scene. To find scenes which have data can use gdallocationinfo again but with the ‘-valonly’ flag and save the values to a text file.
gdallocationinfo -valonly -wgs84 s1_all_scenes.vrt \ 103 1.5 > selected_scenes_values.txt
Can then subset the original list of files with the values file using Python:
import numpy # Read in data to numpy arrays scenes = numpy.genfromtxt("selected_scenes.txt", dtype=str) values = numpy.genfromtxt("selected_scenes_values.txt") # Select only scenes where the value is not 0 scenes_data = scenes[values != 0] # Save to text file numpy.savetxt("selected_scenes_data.txt", scenes_data, fmt="%s")
If you have a very large archive of data and need to find which scenes intersect a point often, having a spatial database with the scene outlines would be a better approach. However, if it isn’t something you do often this quick approach using only the GDAL utilities and a bit of Python is worth knowing.