Hola Nestor,
I guess, what you're looking for is ST_Collect. ST_Multi is not an aggregate
function. It's only useful if you need to bring all rows of a column into a
multi representation.
Salduos
Felix
Gesendet: Mittwoch, 18. April 2018 um 16:18 Uhr
Von: "Néstor Ramires" <[email protected]>
An: "PostGIS Users Discussion" <[email protected]>
Betreff: [postgis-users] Construcción de multipunto a partir de puntos en
polígono
Hola a todos
Tengo los siguientes datos:
CREATE TABLE arboles (
id SERIAL,
raiz geometry(Point, 22185)
);
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(1 1)',22185));
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(1 2)',22185));
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(5 2)',22185));
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(6 2)',22185));
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(5 3)',22185));
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(1 6)',22185));
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(3 6)',22185));
CREATE TABLE patrulla (
id SERIAL,
guardia int,
arboles geometry(MultiPoint, 22185),
region geometry(Polygon, 22185)
);
INSERT INTO patrulla (guardia, region) VALUES (1, ST_GeomFromText('POLYGON((0
0, 0 3, 3 3, 3 0, 0 0))',22185));
INSERT INTO patrulla (guardia, region) VALUES (2, ST_GeomFromText('POLYGON((4
1, 4 4, 8 4, 8 1, 4 1))',22185));
INSERT INTO patrulla (guardia, region) VALUES (3, ST_GeomFromText('POLYGON((2
8, 0 6, 2 4, 2 8))',22185));
INSERT INTO patrulla (guardia, region) VALUES (4, ST_GeomFromText('POLYGON((2
8, 5 6, 2 4, 2 8))',22185));
El objetivo es actualizar el campo arboles de la tabla patrulla, con una
geometría multipunto que contenga todos los árboles de la región. Para ello
utilizo la siguiente sentencia:
UPDATE patrulla mpSET arboles = ST_Multi(r.raiz)
FROM arboles r
WHERE ST_Contains(mp.region, r.raiz);
Que no estaría funcionando como yo esperaba, ya que en las regiones que tienen
más de un árbol en su interior, sólo toma en cuenta el primero de ellos.
¿Alguno puede darme una idea de por dónde apuntar para buscar la solución?
--------------------------------------------------
Hello everyone
I have the following data:
CREATE TABLE arboles (
id SERIAL,
raiz geometry(Point, 22185)
);
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(1 1)',22185));
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(1 2)',22185));
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(5 2)',22185));
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(6 2)',22185));
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(5 3)',22185));
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(1 6)',22185));
INSERT INTO arboles (raiz) VALUES (ST_GeomFromText('POINT(3 6)',22185));
CREATE TABLE patrulla (
id SERIAL,
guardia int,
arboles geometry(MultiPoint, 22185),
region geometry(Polygon, 22185)
);
INSERT INTO patrulla (guardia, region) VALUES (1, ST_GeomFromText('POLYGON((0
0, 0 3, 3 3, 3 0, 0 0))',22185));
INSERT INTO patrulla (guardia, region) VALUES (2, ST_GeomFromText('POLYGON((4
1, 4 4, 8 4, 8 1, 4 1))',22185));
INSERT INTO patrulla (guardia, region) VALUES (3, ST_GeomFromText('POLYGON((2
8, 0 6, 2 4, 2 8))',22185));
INSERT INTO patrulla (guardia, region) VALUES (4, ST_GeomFromText('POLYGON((2
8, 5 6, 2 4, 2 8))',22185));
The objective is to update the Trees field of the patrol table, with a
multipoint geometry that contains all the trees in the region. To do this I use
the following sentence:
UPDATE patrulla mpSET arboles = ST_Multi(r.raiz)
FROM arboles r
WHERE ST_Contains(mp.region, r.raiz);
That would not be working as I expected, as in regions that have more than one
tree inside, just take into account the first of them.
Can anyone give me an idea of where to aim to find the
solution?_______________________________________________ postgis-users mailing
list [email protected]
https://lists.osgeo.org/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/postgis-users[https://lists.osgeo.org/mailman/listinfo/postgis-users]