[Qgis-user] Create Postgres View for a St_Union PostGIS

1520 gis juliermeopensourcedeveloper at gmail.com
Fri Jan 20 04:46:12 PST 2023


Dear users,

I have run a SQL Select [1] in order to Dissolve the features in a PostGIS
table using ST_Union. I can load the Select [1] result as a new layer in
QGIS, but when I try to create a PostgreSQL View [2] for the Select [1], I
get an error message: [ERROR: cannot change name of view column "geom" to
"id". Would anyone give me a hint or direction to solve this problem?

[1]

--CREATE OR REPLACE VIEW geointeligencia.vw_cpma_limites AS
(
SELECT
row_number() over() AS id,
st_union(mue_cpma.geom)::geometry(MultiPolygon,4674) as geom
FROM(
SELECT *
FROM geo.br_municipios_2021
WHERE
NM_MUN IN (
'Afonso Cunha',
'Água Doce do Maranhão',
'Alcântara',
'Aldeias Altas',
'Altamira do Maranhão'
)
AND
SIGLA IN('MA')) AS mue_cpma
);

[2]
CREATE OR REPLACE VIEW geointeligencia.vw_cpma_limites AS
(
SELECT
row_number() over() AS id,
st_union(mue_cpma.geom)::geometry(MultiPolygon,4674) as geom
FROM(
SELECT *
FROM geo.br_municipios_2021
WHERE
NM_MUN IN (
'Afonso Cunha',
'Água Doce do Maranhão',
'Alcântara',
'Aldeias Altas',
'Altamira do Maranhão'
)
AND
SIGLA IN('MA')) AS mue_cpma
-- 
##########################################
*Julierme G Pinheiro*
*SDI Expert & Geoprocessing Specialist*
Phone: +55 61 99994-3569
Website: GIS
<https://www.udemy.com/course/qgis-server-para-iniciantes-instalacao-e-configuracao/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230120/bdeda4b1/attachment.htm>


More information about the QGIS-User mailing list