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

I am making a python code for Arcgis9.3. In this code I have an input feature and I create a Output feature. I want that the output feature is the same geometry type as the input feature. At the moment my code to create the output feature is :

gp.CreateFeatureclass("C:/Users/Desktop/Test/", NameOutFC, "POLYLINE")

But I would like to get the input feature geometry type and use it to create my output feature :

gp.CreateFeatureclass("C:/Users/Desktop/Test/", NameOutFC, GeometryLikeInput)

I found the code with ArcPy :

desc = arcpy.Describe('C:/shapefile.shp')
geometryType = desc.shapeType

if geometryType == 'polygon':
print 'Polygon'
elif geometryType == 'point'

But I can't use it with arcgis9.3.

share|improve this question
up vote 5 down vote accepted

You can use the Geometry object which is available even in 9.3.

enter image description here

The .pdf file for Geoprocessor model in 9.3

The code sample:

rows = gp.SearchCursor("D:/St_Johns/data.gdb/roads")
row = rows.Next()
while row:
    print row.Type

Alternative way is to use Describe method where you could use ShapeType:

import arcgisscripting
gp = arcgisscripting.create(9.3)
gp.workspace = r"C:\Program Files (x86)\ArcGIS\Reference Systems"
fc = r"C:\Program Files (x86)\ArcGIS\Reference Systems\utm.shp"
dsc = gp.describe(fc)
print "ShapeType: \n" + str(dsc.ShapeType)

Which gives you Polygon

share|improve this answer
Yes but in this case i have to chexk all the feature in my shapefile and the return geometry type is the geometry type of each feature. So i am looking for a code which return the geometry of the shapefile directly without reading each row and retrun each feature geometry. – Panvjim0 Apr 30 '14 at 9:32
Then just add a counter in the code and use the while counter < 2 in the code. Shapefile can store only one type of geometry, so you are done when you figure out the geometry type of the first feature. – Alex Tereshenkov Apr 30 '14 at 9:39
@Panvjim0, I've updated my answer to include a cleaner way to access the shape type of a feature class. – Alex Tereshenkov Apr 30 '14 at 11:58

Your Answer


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.