[postgis-users] centroid function

david techer davidtecher at yahoo.fr
Tue Aug 23 02:57:05 PDT 2005


Hi Simon

Centroid depends of concavity (convex or no...) of your polygon...

Use PointOnSurface() in order to being guaranted to have a point on your 
polygon

As U can see

select within(pointonsurface(geomfromtext('SRID=4167;POLYGON((175.5751198833
-39.0650221,175.5748736833 -39.0647769667,175.5741390333
-39.0653570833,175.5733367333 -39.0658673167,175.5723208167
-39.0662389333,175.5722333167 -39.0662678333,175.5717718
-39.0664652333,175.57166665 -39.0664888,175.5672906
-39.0674695333,175.5654770333 -39.0682918333,175.5659457167
-39.0682377667,175.5666397 -39.0678542667,175.5673001167
-39.0675961667,175.5680912167 -39.0673477833,175.5720974333
-39.06651,175.5735548333 -39.0659992167,175.5744165
-39.0655272333,175.5751198833 
-39.0650221))')),geomfromtext('SRID=4167;POLYGON((175.5751198833
-39.0650221,175.5748736833 -39.0647769667,175.5741390333
-39.0653570833,175.5733367333 -39.0658673167,175.5723208167
-39.0662389333,175.5722333167 -39.0662678333,175.5717718
-39.0664652333,175.57166665 -39.0664888,175.5672906
-39.0674695333,175.5654770333 -39.0682918333,175.5659457167
-39.0682377667,175.5666397 -39.0678542667,175.5673001167
-39.0675961667,175.5680912167 -39.0673477833,175.5720974333
-39.06651,175.5735548333 -39.0659992167,175.5744165
-39.0655272333,175.5751198833 -39.0650221))'))

return

within(bool)
-------------------
t



Simon O'Malley wrote:

>Hi All
>
>How accurate is the centroid function. Is  the generated point
>geometry guaranteed to lie within the polygon it was based on. It
>doesn't appear to be the case, the centroid will lie within the
>feature mbr but not neccessarily the polygon itself.
>
>I notice the notes say computation will be more accurate if performed
>by the GEOS module. How do you check if it is using GEOS. My
>postgis_full_version states that GEOS is enabled but is it using it
>for centroid????
>
>Try the following geometry:
>
>select id, AsEWKT(shape) from test1 where id = '4085280';
>   id    |asewkt
> 4085280 | SRID=4167;POLYGON((175.5751198833
>-39.0650221,175.5748736833 -39.0647769667,175.5741390333
>-39.0653570833,175.5733367333 -39.0658673167,175.5723208167
>-39.0662389333,175.5722333167 -39.0662678333,175.5717718
>-39.0664652333,175.57166665 -39.0664888,175.5672906
>-39.0674695333,175.5654770333 -39.0682918333,175.5659457167
>-39.0682377667,175.5666397 -39.0678542667,175.5673001167
>-39.0675961667,175.5680912167 -39.0673477833,175.5720974333
>-39.06651,175.5735548333 -39.0659992167,175.5744165
>-39.0655272333,175.5751198833 -39.0650221))
>(1 row)
>
>create table test2 as select id, centroid(shape) from test1;
>select id, AsEWKT(centroid) from test2;
>   id    |                       asewkt
>---------+-----------------------------------------------------
> 4085280 | SRID=4167;POINT(175.571615250557 -39.0663485015635)
>
>Output of  select postgis_full_version();
>
>POSTGIS="1.0.1" GEOS="2.1.1" PROJ=Rel. 4.4.9, 29 Oct 2004" USE_STATS
>DBPROC="0.3.0" RELPROC="0.3.0"
>
>Simon
>_______________________________________________
>postgis-users mailing list
>postgis-users at postgis.refractions.net
>http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>  
>


	

	
		
___________________________________________________________________________ 
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
Téléchargez cette version sur http://fr.messenger.yahoo.com



More information about the postgis-users mailing list