¡Gracias Felix!
Si, sería el ST_Collect la función que estaba buscando.

Realicé unas pruebas y hasta ahora sólo conseguí que construya un multipunto de 
todos los objetos de la tabla arboles.

CREATE TABLE pepe2 AS (
SELECT ST_Multi(ST_Collect(r.raiz)) AS puntito
FROM (
SELECT (ST_Dump(raiz)).geom AS raiz
FROM arboles, patrulla p
WHERE ST_Contains(p.region, arboles.raiz)
) AS r);

El objetivo es que construya un multipunto por cada póligono, utilizando todos 
los puntos que contiene ése polígono. No me doy cuenta de dónde hacer la 
discriminación por puntos contenidos en polígonos.
Me pueden orientar en la resolución de este ejercicio.

-----------------------------------

Thanks Felix!
Yes, it would be the ST_Collect function that I was looking for.

I made some tests and until now I only managed to build a multipoint of all the 
objects in the trees table.

CREATE TABLE pepe2 AS (
SELECT ST_Multi(ST_Collect(r.raiz)) AS puntito
FROM (
SELECT (ST_Dump(raiz)).geom AS raiz
FROM arboles, patrulla p
WHERE ST_Contains(p.region, arboles.raiz)
) AS r);

The objective is to build a multipoint for each poligono, using all the points 
that this polygon contains. I do not realize where to do the discrimination for 
points contained in polygons.
You can guide me in the resolution of this exercise.


En Wed, 18 Apr 2018 13:00:34 -0300, Felix Kunde <[email protected]> escribió:

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
_______________________________________________
postgis-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/postgis-users

Reply via email to