[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] distance from centroid to the points that form the outer boundary of the polygon
From:       Tom van Tilburg <tom.van.tilburg () gmail ! com>
Date:       2012-07-30 20:05:23
Message-ID: 5016E903.4080301 () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Yamini,

Are you sure that multipolygons is what you want to work with? Since a 
multipolygon can consist of multiple polygons (obviously) who share a 
common centroid that can be way outside your actual polygons.

That said, I would make use of ST_Dumppoints to do that.
Something like:
============
WITH pointsdump AS
(
     SELECT gid, ST_Centroid(geom) AS centre, (ST_Dumppoints(geom)).geom 
AS point FROM polygontable
)

SELECT gid, ST_Distance(centre, point) AS distance FROM pointsdump
===========

Now for every point in a geometry with a known gid you will see the 
distance to it's centroid.
You can do statistics on these numbers with something like:
     SELECT gid, avg(distance) avg, max(distance) max, etc... FROM 
results GROUP BY gid

Cheers,
  Tom

On 30-7-2012 15:04, Yamini Singh wrote:
>
> Hi All,
>
> I am looking for suggestions for the following problem I have at hand.
>
> 1.I have a table that contain multipolygons
>
> 2.I want to calculate the maximum distance of points that form the 
> polygon  from the centroid of the polygon. For example of the polygon 
> is formed of 50 points then I want to have distance of all the 50 
> points from the centroid of the polygon.
>
> I am not sure if someone has done this before. But I am finding it 
> difficult to implement it. Any help in this regards is welcome...
>
>
> Best,
>
> YJS
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users


[Attachment #5 (text/html)]

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi Yamini,<br>
      <br>
      Are you sure that multipolygons is what you want to work with?
      Since a multipolygon can consist of multiple polygons (obviously)
      who share a common centroid that can be way outside your actual
      polygons.<br>
      <br>
      That said, I would make use of ST_Dumppoints to do that.<br>
      Something like:<br>
      ============<br>
      WITH pointsdump AS<br>
      (<br>
      &nbsp;&nbsp;&nbsp; SELECT gid, ST_Centroid(geom) AS centre,
      (ST_Dumppoints(geom)).geom AS point FROM polygontable<br>
      )<br>
      <br>
      SELECT gid, ST_Distance(centre, point) AS distance FROM pointsdump<br>
      ===========<br>
      <br>
      Now for every point in a geometry with a known gid you will see
      the distance to it's centroid.<br>
      You can do statistics on these numbers with something like:<br>
      &nbsp;&nbsp;&nbsp; SELECT gid, avg(distance) avg, max(distance) max, etc... \
FROM  results GROUP BY gid<br>
      <br>
      Cheers,<br>
      &nbsp;Tom<br>
      <br>
      On 30-7-2012 15:04, Yamini Singh wrote:<br>
    </div>
    <blockquote cite="mid:SNT131-W191EDF8C3A988183433217A9C60@phx.gbl"
      type="cite">
      <style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
      <div dir="ltr">
        <p class="MsoNormal">Hi All,<o:p></o:p></p>
        <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
        <p class="MsoNormal">I am looking for suggestions for the
          following problem I have
          at hand.<o:p></o:p></p>
        <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
        <p class="MsoListParagraph"
          style="text-indent:-.25in;mso-list:l0 level1 lfo1"><!--[if \
                !supportLists]-->1.<span
            style="font-size: 7pt; font-family: 'Times New Roman'; \
                ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          </span><!--[endif]-->I have a table that contain \
multipolygons<o:p></o:p></p>  <p class="MsoListParagraph"
          style="text-indent:-.25in;mso-list:l0 level1 lfo1"><!--[if \
                !supportLists]-->2.<span
            style="font-size: 7pt; font-family: 'Times New Roman'; \
">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span><!--[endif]-->I want to calculate the \
maximum distance  of
          points that form the polygon&nbsp; from the centroid
          of the polygon. For example of the polygon is formed of 50
          points then I want
          to have distance of all the 50 points from the centroid of the
          polygon.<o:p></o:p></p>
        <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
        <p class="MsoNormal">I am not sure if someone has done this
          before. But I am
          finding it difficult to implement it. Any help in this regards
          is welcome&#8230;<o:p></o:p></p>
        <p class="MsoNormal"><br>
        </p>
        <p class="MsoNormal">Best,</p>
        <p class="MsoNormal">YJS</p>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
 <a class="moz-txt-link-freetext" \
href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>
 </pre>
    </blockquote>
    <br>
  </body>
</html>



_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic