Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Find center of a polygon

This is a discussion on Find center of a polygon within the MapPoint Desktop Discussion forums, part of the Map Forums category; It would be useful if that page had some diagrams. Averaging the cartesian coordinates is what we used school - ...

  1. #11
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    It would be useful if that page had some diagrams.

    Averaging the cartesian coordinates is what we used school - perhaps it was with smaller polygons.

    Seeing what they've written about the "rectangle and trapezium", I think I see what they are getting at. You might have lots of points at one end of the shape. A simple average will then bring the calculated centre over to that side - when it shouldn't.
    Yes integration is the way to go. It is a long time since I did this, but it looks/sounds like the momentum calculations we used to do at Univ...
    (but in 2d and without the velocity component)


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  2. #12
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103
    When I need to find the (approximate) centriod of a polygon I tend to do the following. Note it is very inaccurate and won't return the exact centroid, if you need it exact you would need to look at the stuff Winwead mentioned earlier with 3d Cartisian Coords.

    Code:
            Dim i As Integer
            Dim x, y As Double
            Dim pt As Integer
            Dim intPoints As Integer
            Dim objShape As MapPoint.Shape
    
            For Each objShape In MyMap.Shapes
    
    
            intPoints = UBound(objShape.Vertices)
    
            x = 0
            y = 0
    
            For pt = 0 To intPoints
                If pt = intPoints Then
                    Exit For
                Else
                    CalcPos(MyMap, objShape.Vertices(pt).Location, dblLat, dblLon)
                    x = x + dblLat
                    y = y + dblLon
                End If
            Next pt
    
            Next
            x = x / intPoints
            y = y / intPoints
    
            objloc = MyMap.GetLocation(x, y, 100)
    
            MyMap.AddPushpin(objloc)
    For CalcPos code see the appropriate article (I can't remember which one it was now)

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Center Point
    By colin_turner99 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-14-2006, 02:38 PM
  2. Finding a geoevent in a polygon
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-15-2005, 03:33 AM
  3. Information within polygon
    By Dazzer in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 04-28-2004, 09:50 AM
  4. Distance from Polygon
    By random0000 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 04-14-2003, 10:18 PM
  5. Query by shape / polygon
    By blackmap in forum MapPoint Desktop Discussion
    Replies: 7
    Last Post: 02-12-2003, 04:35 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96