ThinkGeo.com    |     Documentation    |     Premium Support

Getting Feature Values

I am attempting to get feature values, but the I only get column names with this following line of code:
myLayer.QueryTools.GetFeaturesByColumnValue(FieldIdColumn,FieldIdValue,ReturningColumnsType.AllColumns

When I use this, I can get all my columns names, but I want the values of all of the columns based on the FieldIdValue.

What do I need to do?

Hi Chris,

The method myLayer.QueryTools.GetFeaturesByColumnValue(FieldIdColumn,FieldIdValue,ReturningColumnsType.AllColumns) returns a collection with a dictionary<string, string>, it contains all the keys and values like below.

We just call the dics[key] to read the values.

Hope this is helped.

Thanks,
Peter

So, how would you write that line to return the values?

Hi Chris,

Do you mean how to use this API: GetFeaturesByColumnValue(string columnName, string columnValue, ReturningColumnsType returningColumnType)
? If so, below shows the parameters.

  • columnName: one column for the shapefile which is used to match the value.
  • columnValue: used to match the value of features stored in the columnName, if the value is match return the features.
  • returningColumnType: NoColumns means the features return without any columns; AllColumns means get the features with all columns.

Please see the figure below:

Thanks,
Peter

1 Like

That’s exactly how I have my code written, but I don’t see the values when I check the layer. The only thing I could find are the source columns. can you add a line of code that would show me how I would get the FENAME for example after I run that query?

Chris, check the code below.

        Collection<Feature> features = layer.QueryTools.GetFeaturesByColumnValue("FNODE", "37476728", ReturningColumnsType.AllColumns);
        string fename = features[0].ColumnValues["FENAME"];
1 Like

It worked. Thank you!

Hi Chris,

Very glad to hear it works.

Thanks,
Peter