Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can i calculate single/multiple centroid(point) within polygon either in Arcmap or in MapInfo. Both object(point, polygon) are in defferent layer.

Pls suggest.....

Thanks

share|improve this question
    
ET GeoWizards Polygons to Points has many option (better than arcgis) ian-ko.com/ET_GeoWizards/UserGuide/et_geowizards_userguide.htm see Polygon to Point – Mapperz Apr 11 '12 at 21:32

If you want to change your objects into points (the centroid) you can use this statement thru the MapBasic window in MapInfo Professional:

Update MY_TABLE Set OBJ = Centroid(OBJ)

Do remember to do this on a copy of your data file as your original spatial objects will be replaced with the point!

share|improve this answer
1  
"You need to specify Centroid(obj) in the most recent version on Mapinfo. Using the recommended Centroid() will produce an error." (This was a comment from an anonymous user, who tried to edit the post) – Stephen Lead Aug 7 '14 at 0:34
1  
Thanks, yeah I missed the OBJ parameter to the Centroid() function. I have edited the answer to show the right syntax – Peter Horsbøll Møller Aug 7 '14 at 7:05

In Arc Map you can use the "Feature to Point" tool under Data Management Tools to generate points at the Centroid of each feature. Make sure to leave the Inside option unchecked (some polygons may have centroids outside of the input polygon.

Hope This Helps

share|improve this answer

In Mapinfo you can add fields to a table, then use the update column feature to populate those fields with CentroidX(OBJ) and CentroidY(OBJ)

share|improve this answer
    
...and then use Table > Create Points to create the points. – Mr_Chimp Apr 12 '12 at 9:22

This is an old answer but here are my two cents using Arcpy.

There is a great script from ESRI about creating a point layer of centroids here: http://support.esri.com/cn/knowledgebase/techarticles/detail/41027.

However, if the need is to get the centroid or a point that falls within a polygon, I wrote a little guess-and-check script that will find a point that is within the feature. (I found this necessary because "Feature to Point" tool requires an advanced license.) Here fc is a polygon featureclass.

import arcpy
import random 
random.seed()

pth = "E:/out_path/"
out_file_name = "output_point_file"
arcpy.env.workspace = pth

fc = "PolygonLayer.shp"
cursor = arcpy.da.SearchCursor(fc, ["SHAPE@TRUECENTROID","SHAPE@"])
ptGeomList = []

cent = arcpy.Point()
for feat in cursor:

    cent.X = feat[0][0]
    cent.Y = feat[0][1]
    outside = not feat[1].contains(cent)

    cnt = 0

    while outside:
        if cnt == 1000:
            print "Tried 1000 times, feature might be too small"
            break
        cnt += 1

        xmin = feat[1].extent.XMin
        xmax = feat[1].extent.XMax
        ymin = feat[1].extent.YMin
        ymax = feat[1].extent.YMax
        # Create random numbers within the extent
        #   of the parent feature
        newX = random.random() * (xmax - xmin) + xmin 
        newY = random.random() * (ymax - ymin) + ymin
        cent.X = newX; cent.Y = newY 
        # Then check to see if this is within
        outside = not feat[1].contains(cent)

    ptGeomList.append(arcpy.PointGeometry(cent))

arcpy.CopyFeatures_management(ptGeomList, out_file_name)

Note that this may not work well for small polygons, so I've written this to break after 1,000 attempts at finding a point within the polygon.

share|improve this answer
    
Awesome thanks. I need to push the attribute table of the fc into the point geometry. Was thinking I could write the values to a CSV and then manipulate that way. – dgrubman Jun 8 at 20:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.