<div dir="ltr"><div style="font-family:monospace" class="gmail_default"></div><div dir="ltr"><div class="gmail_default" style="font-family:monospace">Sorry for the late answer.<br>This problem is probably related to ST_Union erroneous behavior in some cases. It was described on this list last month (with multilinestring example). You can try ST_MemUnion - it's slower but should yield correct results.<br>Greetings,<br>Marcin</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">sob., 13 cze 2020 o 03:54 Jonathan Schultz <<a href="mailto:jonathan@schultz.la">jonathan@schultz.la</a>> napisał(a):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
I think I've reached the limit of my PostGIS skills so hoping someone can help me solve a problem.<br>
<br>
What I'm trying to do is create overlays from a collection of overlapping polygons as described here: <a href="http://blog.cleverelephant.ca/2019/07/postgis-overlays.html" rel="noreferrer" target="_blank">http://blog.cleverelephant.ca/2019/07/postgis-overlays.html</a><br>
<br>
The data I am working from is a publicly available dataset of the fire history of Western Australia: <a href="https://catalogue.data.wa.gov.au/dataset/dbca-fire-history" rel="noreferrer" target="_blank">https://catalogue.data.wa.gov.au/dataset/dbca-fire-history</a> I downloaded the data as CSV and loaded it into a PostgreSQL table. That much seems fine.<br>
<br>
I then select a region and dump the MULTIPOLYGONs into POLYGONs using the following query:<br>
<br>
> CREATE TABLE dbca_fire_history_dump AS<br>
>     SELECT fih_perimeter, fih_author, fih_season1, fih_capt_meth, fih_year1, fih_district, fih_burn_purp, fih_detect_fdi, fih_poly_type, fih_fire_type, fih_master_key, fih_number, fih_date1, fih_cause, fih_ignit_type, fih_comment, fih_hectares, fih_hist_distr, fih_fire_seaso, fih_name, (st_dump(geometry)).geom AS geometry FROM dbca_fire_history<br>
>     WHERE st_intersects(geometry, st_makeenvelope(<longmin>, <latmin>, <longmax>, <latmax>, 4326));<br>
<br>
and from there create the boundary polygon using this query:<br>
<br>
> CREATE TABLE dbca_fire_history_boundaries AS<br>
>   SELECT ST_Union(ST_ExteriorRing(geometry)) AS geometry<br>
>     FROM dbca_fire_history_dump;<br>
<br>
This is where things get weird. If I select a small enough region (eg 36S 116E to 35S 117E) the result looks fine. But if I select a slightly larger region (eg 36S 116E to 34S 117E) then the result is very strange - the geometry seems to have snapped to a much larger grid to the extent that it bears no obvious resemblance to the data.<br>
<br>
I've pasted images that demonstrate the result here: <a href="https://pasteboard.co/JcPeDUk.png" rel="noreferrer" target="_blank">https://pasteboard.co/JcPeDUk.png</a> and here: <a href="https://pasteboard.co/JcPfju0H.png" rel="noreferrer" target="_blank">https://pasteboard.co/JcPfju0H.png</a><br>
<br>
Thanks in advance for any help or suggestions.<br>
<br>
Cheers,<br>
Jonathan<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div></div>