1

I'm trying to create a point shapefile from a grid index polygon shapefile I created using ArcPy at ArcGIS 10.0 . I know this is simple, but could anyone give a few pointers out there. Here is what I've done now: but my error is:

Traceback (most recent call last): File "C:\Users\RLong\Documents\NewPoint.py", line 19, in <module> arcpy.FeaturetoPoint_management("GridIndex", "SamplesLoc", "Centroid") AttributeError: 'module' object has no attribute 'FeaturetoPoint_management'

Any ideas?

###Simple point shapefile object for testing
###
###Import standard modules
import os, sys, math, arcpy, traceback, string, fileinput
###Setup your workspace or file you're going to use
from arcpy import env
arcpy.env.workspace = "C:/Users/RLong/GIS_Data/Conversions/GridIndex.shp"
###setup local variables
in_Features = "GridIndex.shp"
point_location = "Centroid"
out_feature_class = "SamplesLoc"

###execute point
arcpy.FeaturetoPoint_management("GridIndex", "SamplesLoc", "Centroid")
1
  • look into point shapefile constructors and see what they take and what methods are involved that can change other files to fit a point shapefile from a grid index polygon shapefile. Dec 4, 2012 at 22:39

2 Answers 2

3

if I remember correctly, you can use Feature To Point (Data Management) for getting centroids of your polygons.

import arcpy 
arcpy.FeatureToPoint_management(inFeat, outFeat, "CENTROID")

i hope it helps you....

2
  • sorry, i havent seen @RyanDalton's answer when i was writing my answer. :)
    – urcm
    Dec 4, 2012 at 23:52
  • I think you answered my question. I really need to understand the Geoprocessor object what is the diff between a put and get. Thx!
    – DATAfiend
    Dec 5, 2012 at 5:34
2

Are you trying to simply generate centroids of the polygons? If so, just use the Feature To Point (Data Management) tool. No need to write your own Python script/tool.

Of course, this assumes you have access to an ArcInfo license, as it is not available for ArcView or ArcEditor.

8
  • This tool does not put point in center of odd shaped features (e.g.) s shaped polygon even if you have the create inside check box checked. I believe there is a tool in ET Geowizard that does.
    – artwork21
    Dec 5, 2012 at 0:02
  • 2
    @artwork21, your statement is correct, but maybe a bit misleading. As long as you have the "inside" check box ticked on, it will create a point somewhere on the surface of the polygon. But you are correct that it will not put the point in the center of oddly shaped or multi-part polygons. Dec 5, 2012 at 0:06
  • Ah, sorry must of forgot to check that check box.
    – artwork21
    Dec 5, 2012 at 2:54
  • @RyanDalton, I just have ARCVIEW 10. I don't got the money for an ARCINFO license.
    – DATAfiend
    Dec 5, 2012 at 5:33
  • 1
    You can select vertices, centroids, centroids inside, or labels with the tool. Newest version of ET GeoWizards is 10.2. I think it has a limit on how many features it will process though. Might have to chop it up.
    – Baltok
    Dec 5, 2012 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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