Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have been given a point shapefile but it's feature class is null. I haven't seen this before so I'm wondering if the data is bad or if it's something I need to handle with code.

//I was using this to determine if my layer was a point layer, but it's FeatureClass is null
public void isPointsLayer(ILayer layer)
{
IFeatureLayer fl = layer as IFeatureLayer;
if (fl == null && fl.FeatureClass == null) return false; 
esriGeometryType type = fl.FeatureClass.ShapeType;
if (type == esriGeometryType.esriGeometryPoint) return true;
}

edit:

I guess ILayer.Valid returned false, thanks for the answers.

share|improve this question
    
If you used code to create the featurelayer, please post that too. If not cast the featurelayer to IDataLayer then cast IDataLayer.datasetname to IDatasetName, and print out IDatasetName.workspacename.pathname. –  Kirk Kuykendall Apr 27 '11 at 22:22
    
Can you see any data on the screen? Is there an exclamation mark in your list of layers? –  Ragi Yaser Burhum Apr 28 '11 at 0:35
    
@Ragi iterationx is (bravely) using arcengine without any desktop apps. (I can't remember, but I don't think the arcengine TOC control will show the red exclamation marks, does it?). –  Kirk Kuykendall Apr 28 '11 at 14:40
    
@Kirk Ah that makes sense. I havent used the TOC control in 6+ years so I dont remember if it does. The reason I asked is exactly because of I had a hunch that it wasnt pointing to anything, but Petr beat me to it :) –  Ragi Yaser Burhum Apr 28 '11 at 14:56
    
@Kirk Kuykendall, I'm not sure, I stopped using the TOC control and programmed my own in with a WPF TreeView, because I'm using dynamic display and setting ILayer max / min visibility breaks the dynamic display engine, and therefore I simulate max / min viz by adding or removing layers when the extent changes, it actually works which is surprising. I wish i had ArcInfo / Editor but my boss won't buy it for me. –  patrick Apr 28 '11 at 15:10
show 1 more comment

1 Answer

up vote 2 down vote accepted

The terminology is actually a bit different - a shapefile's feature class is not null, it's the feature layer which has null feature class reference.

This means that the reference to your data (the shapefile) is broken. This can be checked beforehand through ILayer.Valid property.

share|improve this answer
add comment

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.