Welcome to MapForums!

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

## finding the center of a shape

This is a discussion on finding the center of a shape within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hello again- Is there an object property of a shape(polygon) that can give me a center location, so I can ...

1. Member Green Belt
Join Date
Sep 2008
Posts
63

## finding the center of a shape

Hello again-
Is there an object property of a shape(polygon) that can give me a center location, so I can add a textbox at that location?

Or do I have to decipher it from a calculation?

Or do I have to find a pushpin near the center and use that pushpin as a reference?

If it's not possible, how about just choosing any pushpin within a selected shape and adding a textbox there?

Any suggestions?

THank you-
-Alex

2. ## Re: finding the center of a shape

Some shapes (eg. ellipses and radius circles) have a central location property.
I don't think this is set for freeform shapes. So you will have to calculate it, or find a pushpin in the shape. Note with the latter (which you suggest), there might not be a pushpin in the shape.

Richard

3. Member Green Belt
Join Date
Sep 2008
Posts
63

## Re: finding the center of a shape

Thank you, that stinks that there is no center property for free forms

Which choice would be easier, not neccessarily better, as I am not a programmer and I kind of just haphazardly put together snippets of code I find on the web?

Thank you again for your help.

4. ## Re: finding the center of a shape

Finding a pushpin would be easier as it avoids coding up a geometry algorithm. Do a "QueryShape()" call on the dataset containing the pushpins.

As I said before, beware! Many shapes may not have pushpins?

5. Member Green Belt
Join Date
Sep 2008
Posts
63

## Re: finding the center of a shape

Once again Thank you!

All my shapes will have pushpins, as the nature of what I am doing is drawing free forms around mapped pushpins, to cluster them together into smaller "packets" of around 100-125 pushpins each.

So because all my shapes will have multiple pushpins, is there a way to pick the northern most pushpin, or northern most vertices, or northern most point on the polygon?(just for some kind of continuity- I have anywhere from 15-30 shapes on any one map)

Thanks,
-alex

6. Senior Member Green Belt
Join Date
Sep 2005
Location
Battle Creek, Michigan
Posts
136

## Re: finding the center of a shape

In either case (pushpin or vertice) you could find the northmost or northwestmost item by iterating through the pushpin locations from QueryShape, or vertices of the shape object, and then looking for the highest latitude and longitude values.

If you want to find the visual center of a freeform shape, as opposed to the geometric center, you could also use the iteration process to find the leftmost, rightmost, topmost and bottommost longitudes and latitudes. The visual center is half the difference of each respective value.

HTH
-Paul

7. Member Green Belt
Join Date
Sep 2008
Posts
63

## Re: finding the center of a shape

Paul- thank you for helping.
One thing I tried and it seems to work is getting the union of the vertices. I think it worked similiar if not exactly like what you were describing.

-Alex

8. ## Re: finding the center of a shape

There's a MapInfo Pro tool that does several different kinds of centroids..

spatialSQL for MapInfo - Advanced spatial SQL

You can see the different types illustrated

Geometric Centroid
(Shifted) MBR Centroid
Visual Centroid
Second Visual Centroid --> 'nth VC'

I don't know if those are generally used terms or just for this product..

spatialSQL for MapInfo - Advanced spatial SQL - visual centroid

For mapping I like to use the Visual Centroid.

Unfortunately it only works with MapInfo Pro, not MapPoint.

Eric