4

How can I programmatically determine if a shapefile contains points, polygons, or lines?

ArcEngine 10, VS2010, C#

patrick
  • 2,730
  • 26
  • 50

3 Answers3

6

Searching for arcengine+shapetype will help you find: IFeatureClass Or much faster if you like: check byte 32-35 of the file http://en.wikipedia.org/wiki/Shapefile

johanvdw
  • 6,207
  • 27
  • 42
  • 2
    The problem with links to google in an answer (in general) is that there's a good chance that the #1 result in a little while will be this question. (Assuming this site will accumulate the sort of googlejuice that StackOverflow.com has...) Also, LMGTFY is a touch snarky, which I appreciate, but not everyone does. ;) – Dan S. Feb 24 '11 at 19:03
  • I've added the link which you are supposed to find. Using lmgtfy is educational here. – johanvdw Feb 24 '11 at 19:06
4

you can iterate through the geometry features and determine the type of the geometry feature in a conditional statement using the GetGeometryType method I suggest you go through the API found here: http://geoinformatics.tkk.fi/doc/Geo-GDAL/html/class_geo_1_1_o_g_r_1_1_geometry.html

user39901230
  • 466
  • 5
  • 14
4

You can use IFeatureclass.ShapeType. Opening a featureclass is a bit expensive, I bet johanvdw's method is faster.

Kirk Kuykendall
  • 25,787
  • 8
  • 65
  • 153