I have a PostGIS table with a geometry column (geom
) and a type
column. The geom
column contains only MULTILINESTRINGs
and the type
column contains tags that tell me what each MULTILINESTRING
represents. The tags are just letters. I’m trying to get the bounding box of all the MULTILINESTRINGs
in the table that have type='a'
.
I tried the following but it does not work:
SELECT *
FROM line_table
WHERE line_table.geom && SELECT ST_Envelope(line_table.geom) FROM line_table WHERE type='a';
I’m new to PostGIS and SQL in general so I’m not sure if I’m even close to the answer. Right now I think the problem is that I'm getting one independent envelope for each MULTILINESTRING
where type='a'
instead of the bounding box of all the MULTILINESTRINGs
together. Perhaps there is a way of merging all the MULTILINESTRINGs
of type='a'
into one geometry but so far I have not been able to figure out how.