[postgis-users] Topology: Simplifying Coastlines with Islands

Michiel J. van Heek michielvanheek at nine-e.org
Sat May 26 13:37:14 PDT 2012


Sandro,

I replaced ST_Simplify by ST_SimplifyPreserveTopology, and as a  
result, like you expected, the coastline of Norway was simplified at  
the 0.25 iteration.

So, why not use ST_SimplifyPreserveTopology by default? Or is that  
function generally a lot slower than ST_Simplify?

Michiel

Quoting "Michiel J. van Heek" <michielvanheek at nine-e.org>:

> Hello Sandro,
>
> Thank you for your reply.
>
> These are the warnings for edge 11652, the coastline of Norway (on  
> the screenshot in my previous post):
>
> WARNING:  Simplification of edge 11652 with tolerance 0.5 failed:  
> SQL/MM Spatial exception - geometry crosses an edge
> WARNING:  Simplification of edge 11652 with tolerance 0.25 failed:  
> SQL/MM Spatial exception - curve not simple
> WARNING:  Simplification of edge 11652 with tolerance 0.125 failed:  
> SQL/MM Spatial exception - curve not simple
> WARNING:  Simplification of edge 11652 with tolerance 0.0625 failed:  
> SQL/MM Spatial exception - curve not simple
> WARNING:  Simplification of edge 11652 with tolerance 0.03125  
> failed: SQL/MM Spatial exception - curve not simple
> WARNING:  Simplification of edge 11652 with tolerance 0.015625  
> failed: SQL/MM Spatial exception - curve not simple
> WARNING:  Simplification of edge 11652 with tolerance 0.0078125  
> failed: SQL/MM Spatial exception - curve not simple
>
> The "curve not simple" makes we want to try your suggestion to use  
> ST_SimplifyPreserveTopology instead of ST_Simplify. I will try that  
> tomorrow (it is late in my timezone) and let you know the outcome.
>
> The ticket you mentioned seems to be about creating topology from  
> geometry. That part - SELECT CreateTopology('countries_topology',  
> 4326) - ran flawless in my case. (Long, but without errors.) The  
> ticket is not about simplifying topology, or is it?
>
> Best,
> Michiel.
>
> Quoting Sandro Santilli <strk at keybit.net>:
>
>> On Fri, May 25, 2012 at 06:36:39PM +0200, Michiel J. van Heek wrote:
>>> Dear list,
>>>
>>> I am trying to simplify a dataset of country boundaries by using
>>> topology functions, as described in Strk's Blog:  
>>> http://strk.keybit.net/blog/2012/04/13/simplifying-a-map-layer-using-postgis-topology/
>>>
>>> This has worked quite well, except for coastlines with islands
>>> nearby. The simplified coastline would probably intersect the
>>> island, or pass the island at the wrong side, leading to invalid
>>> topology. Does that mean that countries with coastal islands such as
>>> Canada and Norway (see attached image) cannot be simplified this
>>> way?
>>
>> I think you should figure out more about why the simplification
>> fails. The function in the post raises a WARNING on each failure,
>> what does that warning say ? I'm asking because there's also the
>> case of self-topology breakage, which could be prevented by using
>> ST_SimplifyPreserveTopology rather than ST_Simplify.
>>
>> If your assumption about why simplification fails is correct you
>> could make things better by splitting the complex edge near the
>> islands (see ST_ModEdgeSplit).
>>
>>> Ideally, islands in the way of a to-be-simplified coastline should
>>> be merged with the mainland. (I have already removed the smaller
>>> islands, but I think I should not remove the bigger islands too.)
>>
>> The function in the post is still only considering each edge in
>> turn and has no knowledge of which faces are defined by those
>> edges, let alone which faces define your feature (mainland, island).
>> You'll need something more sofisticated for that, and I'm not sure
>> there's an easy general handling for such cases. I mean, there could
>> still be the case in which simplifying an edge would intersect an
>> island which doesn't belong to the same feature...
>>
>> Let me know what you found when looking closer at the failure messages.
>> There's a ticket to make those messages more useful to understand
>> the problem [1], if you hit that please add to that ticket, and maybe
>> provide also a patch :)
>>
>> [1] http://trac.osgeo.org/postgis/ticket/1817
>>
>> Finally: make sure to run the latest and greatest postgis & GEOS.
>> There have been a few fixes and improvements lately.
>>
>> --strk;
>>
>>  ,------o-.
>>  |   __/  |    Delivering high quality PostGIS 2.0 !
>>  |  / 2.0 |    http://strk.keybit.net - http://vizzuality.com
>>  `-o------'
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>





More information about the postgis-users mailing list