[postgis-users] Reduce precision using ST_union with gridSize

Martin Davis mtnclimb at gmail.com
Tue Apr 6 11:46:54 PDT 2021

The issue with ST_Union not working with an empty polygon certainly sounds
like a bug, and we should look into that. If you can file a ticket that
would be great.   (It would be helpful to have the polygon data which is
causing the problem.  Is it valid?)

In any case now there is the function ST_ReducePrecision [1] which is
specifically designed to do what you want.  (It uses most of the same
machinery as ST_Union, but should avoid whatever the issue with ST_Union

[1] https://postgis.net/docs/manual-3.1/ST_ReducePrecision.html

On Tue, Apr 6, 2021 at 7:28 AM Palacios García Cuevas, Elena <
epgcuevas at indra.es> wrote:

> Hello,
> I am trying to simplify a polygon by reducing the precision using ST_Union
> with the gridSize parameter ( I am using  postgis 3.1  and GEOS 3.9.1). I
> have read that it is possible to do that by a union of a geometry with an
> empty geometry (
> http://blog.cleverelephant.ca/2020/12/waiting-postgis-31-3.html).
> However, does not works for me ( maybe is my fault because I am new with
> postgis). I have tried as follows:
> *CREATE TABLE public.error_union_empty*
> *(*
> *    geom geometry(MultiPolygon),*
> *    gid integer NOT NULL DEFAULT nextval('fallo_gid_seq'::regclass),*
> *    CONSTRAINT error_union_empty_pkey PRIMARY KEY (gid)*
> *);*
> *INSERT INTO error_union_empty*
> *(SELECT ST_union(geom,ST_GeomFromText('POLYGON EMPTY'), 0.001152) geom*
> *FROM f_polygon);*
> But the result is an empty table.
> Then I tried to do the same but by doing the union with the polygon
> himself, and this approach seems to work ok.
> *CREATE TABLE public.error_union_empty2*
> *(*
> *    geom geometry(MultiPolygon),*
> *    gid integer NOT NULL DEFAULT nextval('fallo_gid_seq'::regclass),*
> *    CONSTRAINT error_union_empty2_pkey PRIMARY KEY (gid)*
> *);*
> *insert into error_union_empty2*
> *select  ST_CollectionExtract(ST_union(f_polygon.geom,f_polygon.geom,
> 0.001152)) geom *
> *from f_polygon;*
> Why is not working the first approach? Have I missed something in the
> query?
> Any help or comments are welcome.
> Does anyone knows if  is expected to have a simplify with gridsize in the
> future?
> Thanks!
> ------------------------------
> Este correo electrónico y, en su caso, cualquier fichero anexo al mismo,
> contiene información de carácter confidencial exclusivamente dirigida a su
> destinatario o destinatarios. Si no es vd. el destinatario indicado, queda
> notificado que la lectura, utilización, divulgación y/o copia sin
> autorización está prohibida en virtud de la legislación vigente. En el caso
> de haber recibido este correo electrónico por error, se ruega notificar
> inmediatamente esta circunstancia mediante reenvío a la dirección
> electrónica del remitente.
> Evite imprimir este mensaje si no es estrictamente necesario.
> This email and any file attached to it (when applicable) contain(s)
> confidential information that is exclusively addressed to its recipient(s).
> If you are not the indicated recipient, you are informed that reading,
> using, disseminating and/or copying it without authorisation is forbidden
> in accordance with the legislation in effect. If you have received this
> email by mistake, please immediately notify the sender of the situation by
> resending it to their email address.
> Avoid printing this message if it is not absolutely necessary.
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20210406/5e8f3d2a/attachment.html>

More information about the postgis-users mailing list