How to determine which images of the earth's surface overlap with any given image?

Suppose you are given an image of the earth's surface and that it is stored in the database as a polygon defined by pairs of latitude / longitude of its angles.

Now suppose that millions of images cover the earth's surface, which are also stored similarly. What is a good strategy for finding images that intersect with your image?

I have a working basic algorithm based on the "bounding radius" of images. But this is not optimal and finds more images than should be returned.

I looked at the spatial features of MySQL GIS, but all the calculations that seem to be done in Euclidean geometry.

In fact, I just need a function that returns true or false depending on whether the two polygons intersect (on a sphere and given by lat / long points). Seems simple, but I haven't found an implementation yet. And the thought of understanding it myself is tiring.

+3
source share
2 answers

Using PostGIS, you can run something like:

SELECT b.* 
FROM images AS a
 JOIN images AS b
 ON ST_Intersects(a.the_geom,b.the_geom)
WHERE a.name = "The image you are interested in"

This assumes that all the borders of the images are contained in the same PostGIS “image” table.

+2
source

I personally use PostGIS and GEOS (via geodjango ) to solve this problem.

+1

Source: https://habr.com/ru/post/1764814/


All Articles