I am trying to find all the neighborhoods located between two (or more) neighborhoods. The definition of between is obviously a bit fuzzy but for our purpose, I'd like to extract all neighborhoods that overlap with the shape connecting two disjoint shapes.
For this, I am trying to build a polygon merging two polygons and including everything in between the two. I am not very familiar with the terminology, so I hope the following picture helps understand better what I am trying to do.
I am using PostgreSQL with PostGIS extension.
Source polygons
Desired output polygon
How could I write a PostGIS query to get this? I tried the following but without success:
SELECT ST_MakePolygon(ST_ExteriorRing(ST_Union(shape)))
FROM (
SELECT *, 1 as group_id
FROM subquery
) a
GROUP BY group_id
where subquery
is just a table with the selected neighborhoods. shape
is a polygon.
Thanks a lot for your help!