ThinkGeo.com    |     Documentation    |     Premium Support

Detecting Shapefile Feature type

Is there a built-in mechanism for detecting whether the Shapefile is of LINE POINT OR POLYGON type? Just wondering.


 


 



Oh yes, I’d like to know that too…I have an app that helps build styles and it would be nice to let the user to just set the style for a layer’s feature type…nothing gained by setting a line or area style for a point.  I poked around a layer’s innards a few months ago and couldn’t find anything.  
  
 Allen

I'm sure we could acheive this by looking at the Column "SHAPE" as its value will be either Polygon Line or Point so long as you are using a standard shapefile (I believe). I just wanted to know if there was a built-in function so I didn't re-create the wheel. Thanks again.






 


Nelson and Allen,


Here is the built-in method you are looking for.



ShapeFileFeatureLayer statesLayer = new ShapeFileFeatureLayer"USStates.shp");
statesLayer.Open();
ShapeFileType type = statesLayer.GetShapeFileType();

One thing to be aware is that the ShapeFileType not only includes Point, PolyLine, Polygon, MultiPoint, MultiPolyLine and MultiPolygon, it also includes other types like MultiPointM or MultiPointZ. For more information, please see Page 4 of esri.com/library/whitepa...pefile.pdf


Allen, you can use PointStyle to render all the point related types(Point, MultiPoint, MultiPointM and MultiPointZ), it's similar for LineStyle and AreaStyle too.


Thanks,


Ben




That's great, Ben. Thos various types can be filtered down to the base types. Thank you again.



That’s my pleasure, Nelson.

Hi All, 
  
 One more question to add here. How detect SRID of the ShapeFileFeatureLayer. I have notice there is a property in postgresfeatureLayer as SRID. Isn’t there any work around to get projection text even? 
  
 Thanks 
 Amila

 Amilia,


 
Thanks for your question!
 
Typically projection information for shapefiles is saved in a *.prj file along with the other shapefile files.  Here is a link to a sample that shows how to read the *.prj information and get the right projection information.
 
wiki.thinkgeo.com/wiki/Map_S...g_Prj_File
 
Let us know if you have any additional questions.
 
Thanks!