Hi,
I am trying to obtain a subset of features from a large shapefile based on an attribute value. The shapefile has about 800,000 records in it. My current approach is outlined in the following code snippet:
I tried to obtain about 600 records from the featuresource and it took about 3 mins for the code to finish execution. This time penalty is too huge to be acceptable. Is there a better way to do it ?
public IEnumerable<Feature> GetFeaturesByColumnValues(string columnName, ICollection<string> columnValues)
{
var featureCollection = new List<Feature>();
FeatureLayer.Open();
var columns = FeatureLayer.FeatureSource.GetColumns();
foreach (var column in columns)
{
if(String.Equals(column.ColumnName,columnName))
{
foreach (var value in columnValues)
{
var features = FeatureLayer.FeatureSource.GetFeaturesByColumnValue(columnName, value);
featureCollection.AddRange(features);
}
break;
}
}
FeatureLayer.Close();
return featureCollection;
}