[postgis-tickets] [PostGIS] #4711: ST_Union loses precision on complex multilinestring geometries

PostGIS trac at osgeo.org
Mon Jun 29 09:52:31 PDT 2020


#4711: ST_Union loses precision on complex multilinestring geometries
------------------------+---------------------------
 Reporter:  dannytoone  |      Owner:  pramsey
     Type:  defect      |     Status:  new
 Priority:  medium      |  Milestone:  PostGIS 3.1.0
Component:  postgis     |    Version:  2.5.x
 Keywords:              |
------------------------+---------------------------
 Version info:

 PostgreSQL 12.3, compiled by Visual C++ build 1914, 64-bit POSTGIS="3.0.1
 3.0.1" [EXTENSION] PGSQL="120" GEOS="3.8.0-CAPI-1.13.1 " PROJ="Rel. 5.2.0,
 September 15th, 2018" LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1"
 WAGYU="0.4.3 (Internal)"


 I have a process where I am trying to analyze FCC license spectrum
 geographic boundaries across multiple frequency ranges. I am trying to
 follow a process very similar to this blog post:

 http://blog.cleverelephant.ca/2019/07/postgis-overlays.html

 The license boundaries, when viewed across several overlapping licenses
 that are broadcasting on different frequencies, is quite complex. When
 unioning the various linestrings via ST_Union, I get very odd results. I
 have found that somehow ST_Union is losing precision on the underlying
 datapoints.


 {{{
 create temp table all_rings AS
 select distinct ST_ExteriorRing((ST_Dump(geom)).geom) as geom
 from call_sign_polys
 where geom && ST_MakeEnvelope(-79.762152,40.496103,-71.856214,45.01585)
 ;
 }}}

 The underlying rows have several decimal places of precision.


 {{{
 select left(ST_AsText(geom),100)
 from all_rings;
 ========
 LINESTRING(-74.911677 39.463256,-74.903864 39.457263,-74.897414
 39.452315,-74.893314 39.449815,-74.8
 LINESTRING(-79.293682 40.040413,-79.29359 40.040398,-79.293681
 40.040272,-79.294509 40.039114,-79.29
 LINESTRING(-79.2999533093807 40.4383075755913,-79.315177512369
 40.3395369154545,-79.3552093057337 40
 LINESTRING(-79.2999533093807 40.4383075755913,-79.315177512369
 40.3395369154545,-79.3552093057337 40
 }}}

 However, all of that precision is lost when ST_Union is called:


 {{{
 select left(ST_AsText(ST_Union(geom)),200)
 from all_rings;
 ==================
 MULTILINESTRING((-75 39,-76 39,-76 40),(-76 40,-75 40),(-75 40,-75
 41),(-75 40,-74 40),(-75 40,-75 39),(-79 40,-80 40),(-80 40,-81 40),(-81
 40,-81 41),(-81 41,-80 41),(-80 41,-79 41),(-79 41,-79 40),(
 }}}

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4711>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list