[postgis-users] Topology: Simplifying Coastlines with Islands

Michiel J. van Heek michielvanheek at nine-e.org
Mon May 28 05:50:43 PDT 2012


Quoting Sandro Santilli <strk at keybit.net>:

> On Mon, May 28, 2012 at 11:56:13AM +0200, Michiel J. van Heek wrote:
>
>> Based on your suggestions, I changed the script in three ways (see
>> below for the result):
>>
>> 1. The number of iterations is now a parameter and running down the
>> tolerance uses linear steps for each iteration (0.5, 0.45, 0.4,
>> 0.35, etc.). The division by 2 solution (0.5, 0.25, 0.125, etc.) put
>> a heavy weight on the lower tolerances, whereas it is often
>> worthwile to also try higher tolerances (between initial tolerance
>> and half of the initial tolerance).
>>
>> 2. If an iteration fails because of "not simple" the same iteration
>> is run again, but with "PreserveTopology" now.
>>
>> 3. When all iterations fail, the function returns NULL now, and does
>> not throw an exception. It is now possible to find "unwilling" edges
>> by running:
>>
>> SELECT *
>> FROM (
>>     SELECT
>>         edge_id,
>>         SimplifyEdgeGeom('countries_topology_4', edge_id, 0.5) AS tolerance
>>     FROM countries_topology_4.edge
>> ) AS foo
>> WHERE (tolerance IS NULL);
>
> Good work ! Maybe make the "curve not simple" handling more tolerant of
> eventual changes in the exception text (only look for "not simple"?).

Good that you mention it. Here is the improved IF line:

                 IF (position('not simple' IN SQLERRM) > 0) AND (xi = '') THEN

But still, this mechanism strongly depends on the formulation of the  
exceptions thrown in ST_ChangeEdgeGeom().

> How do your country boundaries look now ? :)

They look pretty good. Most remaining trouble edges are relatively  
short. Three long coastlines remain problematic: arctic Canada,  
southern/eastern USA, and Brazil. (Red color in attached screenshot.)  
Probably because they have some quite large islands very close to the  
coastline. If we want to handle these kind of cases automatically, the  
easiest way would be to removed the islands, but I don't like that  
idea, because some islands may be very big, like the arctic islands of  
Canada. It is like removing Great Britain from the map. :-)

Michiel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot.png
Type: image/png
Size: 291702 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120528/9fe37d74/attachment.png>


More information about the postgis-users mailing list