Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AndrewAnnex/6402356ef10ed83918de98be1cc9e43e to your computer and use it in GitHub Desktop.
Save AndrewAnnex/6402356ef10ed83918de98be1cc9e43e to your computer and use it in GitHub Desktop.
Example QGIS SQL query to select MRO CTX stereo pair candidate files from the Mars ODE footprint shapefile. Polygon text should be updated to wkt polygon for query region of interest. This is ugly but fast enough for a small query region of a few degrees. other settings can be tweaked as needed. Reference https://zenodo.org/record/3817469
SELECT
a.ProductId as left_pi,
b.ProductId as right_pi,
a.EmAngle as left_em,
b.EmAngle as right_em,
a.Ext2URL as left_url,
b.Ext2URL as right_url,
st_intersection(a.geometry, b.geometry) as geom,
st_area(st_intersection(a.geometry, b.geometry)) as ovarea,
st_area(st_intersection(a.geometry, b.geometry)) / st_area(a.geometry) * 100 as overlap_percentage,
ABS(b.EmAngle - a.EmAngle) as diff_em
FROM
mroctx as a,
mroctx as b
WHERE
st_intersects(a.geometry, st_geomfromtext('Polygon ((...))'))
AND
st_intersects(b.geometry, st_geomfromtext('Polygon ((...))'))
AND
st_overlaps(a.geometry, b.geometry)
AND
a.EmAngle < 4
AND
a.EmAngle < b.EmAngle
AND
diff_em > 10
AND
diff_em < 25
ORDER BY
ovarea desc,
diff_em desc,
left_em asc
LIMIT 1000;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment