Search code examples
postgresqlpostgisqgis

separate each points element on different polygon layers on qgis


I have a table called all_the_points which contains several points in rows for every element in a column, now all the elements are in the column called origin,
now each element can have several points, is possible for me to separate all points by their element on different layers on PostGIS in one view, I tried using the group by but still all my points and polygon are on one layer when I drag to my qgis. Thank you

 with 
bounds as (
    select
     origin
    ,min(x) as xmin
    ,min(y) as ymin
    ,max(x) as xmax
    ,max(y) as ymax
    from all_the_points
    group by  WHERE ((all_the_points.origin)::text = '126af84e-0a9b-407d-8036-1ffc316106dd'::text);
)
select 
 origin
,st_makepolygon(st_makeline(array[
     st_makepoint(xmin,ymin)
    ,st_makepoint(xmax,ymin)
    ,st_makepoint(xmax,ymax)
    ,st_makepoint(xmin,ymax)
    ,st_makepoint(xmin,ymin)
]))
from bounds

Solution

  • different layers on PostGIS in one view

    No, this is not possible.

    There are several options:

    • have one layer, and apply a different symbology for each category in QGIS

    • have one layer and filter data for a single category in QGIS. Eventually add the same layer a 2nd (and more) time and filter another category

    • have a distinct view in Postgres for each layer