TransWikia.com

Getting features from given geometry in map using ArcObjects with C#?

Geographic Information Systems Asked by royan on May 11, 2021

I am trying to get features from a given geometry (getting only layers ). This is not selection. The validate part I will be doing using configuration. But I am not able to get the features from the geometry.Even I thought to open an attribute table and check how many rows are there and if I can find the values for each row. But no luck. Here is what I did:

IFeatureClass pFeatureClass= null;
while ((pThisLayer = pEnumLayer.Next()) != null)
  {
 pThisFeatLayer = pThisLayer as IFeatureLayer;

 IFeatureCursor pFtCur = pThisFeatLayer.Search(spatialFilter, false);
 pTable = (ITable)pThisFeatLayer;
 pFeatureClass = pThisFeatLayer.FeatureClass;
                
 //pFields = (IFields)pFeatureClass;
  pFt = pFtCur.NextFeature();
  if (pThisFeatLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
  {
        continue;
  }
  if (pFt != null)
  {

      pCursor = pTable.Search(spatialFilter, false);
      pRow = pCursor.NextRow();
      while (pRow != null)
      {
        //string.IsNullOrEmpty(output);
                       
        //output += pRow.get_Value(count).ToString() + "n";
        MessageBox.Show(pFt.Class.AliasName.ToString()+ "  " +count.ToString());
        count++;
        pRow = pCursor.NextRow();

       }

  }

}

pFt = pFtCur.NextFeature(); statement instead of returning the next feature it returns the next layer. I also tried to get help from ESRI sites but those are down for maintenance.

One Answer

I'm not sure what would cause the behavior you are seeing, but I would recommend changing this line:

IFeatureCursor pFtCur = pThisFeatLayer.Search(spatialFilter, false);

to:

IFeatureCursor pFtCur = pThisFeatLayer.FeatureClass.Search(spatialFilter, false);

Answered by danielm on May 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP