ThinkGeo.com    |     Documentation    |     Premium Support

Filtering features based on attributes

Are there any built-in tools that can query features? I’m looking for something that, given a column name, return features equal to the criteria given.

Here’s an example:

A collection of features, where each feature has a column named “Population”. I want to get a subset of those features where the population is > 5000 (or = 5000, or < 5000). I was going to build a custom tool to this but if there’s something already built in that would be great. Thanks!

Hi Dan,

If you only need equal a specified value you can use this API: shapeFileLayer.QueryTools.GetFeaturesByColumnValue

But if you also want to get “>” or “<” you should want to try this: shapeFileLayer.QueryTools.ExecuteQuery(“Your Sql Statement”)

And I think write a custom function should be another choice here.

Regards,

Ethan

Thank you, that works fine. I noticed ExecuteQuery function returns a datatable. How do I convert that datatable into a collection of features?

Hi Dan,

You should want to loop the table, get the valid data you need and add them into your collection.

Regards,

Ethan