Database Reference
In-Depth Information
the
ST_GeometryN
function,whichisabletoextractthe
nth
ringfromthepolygon.
We coupled this function with the useful PostgreSQL
generate_series
function
to iterate all of the rings composing the geometry, selecting the desired one using
the
ST_Intersects
function.
Asexpected,thereasonwhythisringgeneratestheinvalidityisthatitisself-inter-
sectingandproducesaholeinthepolygon.Whilethisisadherentwiththeshapefile
specification, it isn't so with the OGC specification.
By running the
ST_MakeValid
function, PostGIS has been able to make the geo-
metryvalid,generatingasecondring.Rememberthatthe
ST_MakeValid
function
is available only with the latest PostGIS compiled with the latest GEOS (3.3.0+). If
thatisnotthesetupforyourworkingboxandyoucannotupgrade(upgradingisal-
waysrecommended),youcanfollowthetechniquesdiscussedinaverypopular,ex-
cellentpresentationbyPaulRamseyat
http://blog.opengeo.org/2010/09/08/tips-for-