Spatial Query

07-18-2017 04:16 AM
New Contributor II


i'm developing gis xamarin app

how i can make spatial query

i select 1 region from first layer

and i want to select all cities within selected resgion

i pass geometry of selected feature to the query but it not work

any help plz 

0 Kudos
2 Replies
Occasional Contributor III

Hi Mohammed,

Using GeometryEngine.Intersection() method, I was able to select the cities with a state. Below is the code, since it has the XAML part for the Graphics Overlay, I have attached the project, the project is in WPF..

// City Layer
FeatureLayer cityLayer = new FeatureLayer(new Uri(""));

// State Layer
FeatureLayer stateLayer = new FeatureLayer(new Uri(""));


// State Query
QueryParameters stateQueryParameters = new QueryParameters();

// only select one polygon from State layer
stateQueryParameters.WhereClause = "state_name = 'California'";

// Query the State feature table
FeatureQueryResult stateQueryResult = await stateLayer.FeatureTable.QueryFeaturesAsync(stateQueryParameters);
var stateResult = stateQueryResult.ToList();

// City Query
QueryParameters cityQueryParameter = new QueryParameters();
cityQueryParameter.WhereClause = "1=1";

// Query the City feature table
FeatureQueryResult cityQueryResult = await cityLayer.FeatureTable.QueryFeaturesAsync(cityQueryParameter);
var cities = cityQueryResult.Select(feature => feature.Geometry);

var citiesWithinState = cities
.Select(city => GeometryEngine.Intersection(city, stateResult[0].Geometry))
.Select(city => new Graphic(city, _markerSymbol));

foreach (Graphic g in citiesWithinState)


Hope that helps.


New Contributor II

Thank you very much Nagma

its worked with me

but i have problem

by rendering graphics the result is 100% true

but when i make add watch and i tracing the (citiesWithinState) parameter it not have just features withen first result geometry

it have all cities in the gdb (because i want to binding cities name also how i can get it)

0 Kudos