<p><font size=2 face="sans-serif">Having a centroid outside a polygon is
a common situation, even with valid geometries.</font>
<p><font size=2 face="sans-serif">Depending of use case, I use </font><font size=3>ST_PointOnSurface</font><font size=2 face="sans-serif">
when </font><font size=3>ST_Within(St_Centroid(surface), surface) returns
false</font>
<p><font size=3>steve</font>
<p>
<p>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Rémi Cura <remi.cura@gmail.com>@lists.osgeo.org</b>
</font>
<br><font size=1 face="sans-serif">Envoyé par : postgis-users-bounces@lists.osgeo.org</font>
<p><font size=1 face="sans-serif">2014-05-05 07:09</font>
<table border>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Veuillez répondre à<br>
PostGIS Users Discussion <postgis-users@lists.osgeo.org></font></div></table>
<br>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">A</font></div>
<td><font size=1 face="sans-serif">PostGIS Users Discussion <postgis-users@lists.osgeo.org></font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Objet</font></div>
<td><font size=1 face="sans-serif">Re: [postgis-users] Point inside a polygon</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br>
<br>
<br><font size=3>Hmm your problem is not about a function, is about using
invalid geometries !</font>
<br><font size=3><br>
Why simply don't fix your geometry?</font>
<br><font size=3>you must do it anyway if you want to use PostGIS <br>
without strange bugs.<br>
</font>
<br><font size=3>Use </font><a href=http://postgis.refractions.net/docs/ST_MakeValid.html><font size=3 color=blue><u>http://postgis.refractions.net/docs/ST_MakeValid.html</u></font></a><font size=3><br>
</font>
<br><font size=3>Cheers,<br>
Rémi-C</font>
<br><font size=3><br>
</font>
<br><font size=3>2014-05-03 15:51 GMT+02:00 Larry Reeder <</font><a href=mailto:lnreeder@gmail.com target=_blank><font size=3 color=blue><u>lnreeder@gmail.com</u></font></a><font size=3>>:</font>
<br><font size=3>Another thing to be aware of with ST_PointOnSurface is
it can return a point that's on the boundary of polygon, but *not inside*
the polygon, so that ST_Within(St_PointOnSurface(surface), surface) returns
false.  That's bitten me before, but may be OK for your purposes.</font>
<br>
<br><font size=3 color=#888888>       -Larry</font>
<br>
<br>
<br><font size=3><br>
</font>
<br><font size=3>On Fri, May 2, 2014 at 1:38 PM, Åsmund Tokheim <</font><a href=mailto:asmundto@gmail.com target=_blank><font size=3 color=blue><u>asmundto@gmail.com</u></font></a><font size=3>>
wrote:</font>
<br><font size=3>Hi</font>
<br>
<br><font size=3>You can use st_closestpoint(geom, st_centroid(geom)) to
make sure that the returned point is in most circumstances at or near the
centroid, and always at least on the boundary of the polygon. While st_pointonsurface
certainly will be faster, it will often choose a more random point on the
surface.</font>
<br>
<br><font size=3 color=#888888>Åsmund</font>
<br><font size=3><br>
</font>
<br><font size=3>On Fri, May 2, 2014 at 12:45 PM, Nicolas Ribot <</font><a href=mailto:nicolas.ribot@gmail.com target=_blank><font size=3 color=blue><u>nicolas.ribot@gmail.com</u></font></a><font size=3>>
wrote:</font>
<br><font size=3>Hi,</font>
<br>
<br><font size=3>Use st_pointOnSurface (</font><a href="http://postgis.net/docs/manual-2.1/ST_PointOnSurface.html" target=_blank><font size=3 color=blue><u>http://postgis.net/docs/manual-2.1/ST_PointOnSurface.html</u></font></a><font size=3>)</font>
<br>
<br><font size=3 color=#888888>Nicolas</font>
<br><font size=3><br>
</font>
<br><font size=3>On 2 May 2014 06:32, J.Alejandro Martinez Linares <</font><a href=mailto:islanis@infomed.sld.cu target=_blank><font size=3 color=blue><u>islanis@infomed.sld.cu</u></font></a><font size=3>>
wrote:</font>
<br><font size=3>Hi people, i need your help, i was using st_centroid to
get a point that be inside a polygon butr st_centroid got a property  that
is a problem to me, it returns a point that not always is inside the polygon,
cause when the polygon has an irregular form, the point that st_centroid
is outside the polygon, and i need a function that do a similar thing that
st_centroid but i need that the point it returns always be inside the polygon,
is there a function that do that?<br>
<br>
cheers.<br>
<br>
--<br>
<br>
Este mensaje le ha llegado mediante el servicio de correo electronico que
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema
Nacional de Salud. La persona que envia este correo asume el compromiso
de usar el servicio a tales fines y cumplir con las regulaciones establecidas<br>
<br>
Infomed: </font><a href=http://www.sld.cu/ target=_blank><font size=3 color=blue><u>http://www.sld.cu/</u></font></a><font size=3><br>
<br>
_______________________________________________<br>
postgis-users mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:postgis-users@lists.osgeo.org" target=_blank><font size=3 color=blue><u>postgis-users@lists.osgeo.org</u></font></a><font size=3 color=blue><u><br>
</u></font><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target=_blank><font size=3 color=blue><u>http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</u></font></a>
<br>
<br><font size=3><br>
_______________________________________________<br>
postgis-users mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:postgis-users@lists.osgeo.org" target=_blank><font size=3 color=blue><u>postgis-users@lists.osgeo.org</u></font></a><font size=3 color=blue><u><br>
</u></font><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target=_blank><font size=3 color=blue><u>http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</u></font></a>
<br>
<br><font size=3><br>
_______________________________________________<br>
postgis-users mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:postgis-users@lists.osgeo.org" target=_blank><font size=3 color=blue><u>postgis-users@lists.osgeo.org</u></font></a><font size=3 color=blue><u><br>
</u></font><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target=_blank><font size=3 color=blue><u>http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</u></font></a>
<br>
<br><font size=3><br>
_______________________________________________<br>
postgis-users mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:postgis-users@lists.osgeo.org"><font size=3 color=blue><u>postgis-users@lists.osgeo.org</u></font></a><font size=3 color=blue><u><br>
</u></font><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target=_blank><font size=3 color=blue><u>http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</u></font></a>
<br><tt><font size=2>_______________________________________________<br>
postgis-users mailing list<br>
postgis-users@lists.osgeo.org<br>
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</font></tt>
<br>
<br>
<br>