Hello again. I am having some issues using the QueryTools.GetFeaturesIntersecting function. When I click on the map, I am taking the XY Location of my mouse click (e.WorldX/e.WorldY) and then creating a rectangle shape, which is sized depending on the zoom level. I then am taking that shape and using it to find features from a basemap layer that intersect it.
Ex. features = targetShapefileLayer.QueryTools.GetFeaturesIntersecting(myRectangleShape, ReturningColumnsType.AllColumns).
It seems like sometimes the process works and I get the feature I wanted. Other times, it picks another nearby feature or one even further away. I started adding my rectangle shapes to an InMemoryFeatureLayer and displaying them on the map to show the differences. I am attaching a Word document with a screen shot showing my rectangle shapes (red circles) and arrows pointing to the feature it selected based off of the intersection.
I have tried using GetFeaturesNearestTo (using a new PointShape based off of e.WorldX/e.WorldY) and GetFeaturesOverlapping (using the rectangle shape), but I didn’t not get any better results.
Let me know if there is something I am missing? I am also e-mailing forumsupport@thinkgeo.com with information on how to get a hold of my project, if necessary.
SpatialJoinIssues.doc (206 KB)
Query Tools Get Features Intersecting
Hi Brandon,
I guess you may be in the below case, but not pretty sure if this is the reason of your issue.
When we call the GetFeatureIntersecting/NearestTo/Overlapping, there might be a feature which is a multi-polygon and some of its sub polygons are far away from the select area. Something like this:
The red circle means our searching area and in that case, we can see the polygon 2 is also selected.
The solution: if this is the exact reason of your issue, I think you can try the below ways:
- After you get the selected feature(which might be a multi-polygon), we split it into multiple single polygon, and then do the Intersect or overlap with them each other. Then we should only get the expect one.
If your issue is not like the above one, please let us know, or it is better you can create a small sample to recreate it.
Thanks,
Troy
Hi Troy… I went through the parcel features that I was testing on, and none of them were multipart features. I e-mailed ForumSupport@thinkgeo.com yesterday along with the FTP to grab my simplified project. I couldn’t e-mail it due to restrictions on my end and do not wish to post my code to a public forum.
Take a look at it and let me know what you guys come up with. Thanks!
Further update… I tried a few things to see what might be an issue. For the parcels layers I am using, I double/triple/etc checked the geometry and it checked out. If there were any multipart features, I split them and rechecked geometry. I even tried removing the custom projection from the information (in case that somehow was an issue) but still had the issue. I tried loading up another parcels layer for a different area, and I was having the same issue.
I went back to my original study area which used large polygons that I was selecting features from. That layer did not seem to have any issues selecting the correct feature. Perhaps the software has issues intersecting smaller polygons in larger datasets? My logic in both the large polygons and small polygons is the same so I don’t see where the issue would be.
I went through and made screen captures of what I am experiencing. You can see on the one named OtherParcels that sometimes the correct feature is selected, but other times it isn’t. So, I am not sure what it is since I am using the green rectangle feature to run an intersection against the parcels to select a feature.
Any help is desperately needed.
CaptureVideos.zip (603 KB)
Hi Brandon,
We have received your email but when we check the project, it is so large that we are still downloading now.
I checked your video and I have some guessing. In the video, the green rectangle is used to intersect the blocks or some polygon features, as the rectangle is small and I don’t think use the intersection is suit for your case but using QueryTools.GetFeaturesContaining(clickpoint) is better. I think we can try to modify it here at first.
Then, as the project is too large and I noticed your scenario is not complex, I would suggest we should create a small sample to narrow down this issue. First of all, we can cut off your shape file with an area like in the OtherParcels video any places can show the issue and then we create a small sample to mock your scenario based on the cut off shape file.
As for how to cut off a shape file, I think we can use the GisEditor(free) to achieve it or you can find another GisTool to implement it. I took a video to show how to do it in GisEditor.
screencast.com/t/i0nC78n8jwL
I can understand how urgent in your end and we will try our best to help you to go though it.
Regards,
Troy