Query via Polygon...?

Apr 4, 2016 at 6:46 PM
This is a fantastic tool and the possibilities are very inspiring!

My immediate intent is to use a polygon to query a table that includes Lat/Long fields. In pseudoSQL this would be something like:

SELECT Field1 WHERE Lat/Long=Polygon1 FROM FeatureTable.

So far, my poking around in MapWindow5 isn't getting any traction on this. Is there a video from MapWindow4 that's similar enough to get me started in the right direction? Is this a current capability of MapWindow5 at this point or am I in uncharted territory?

-Leland
Apr 4, 2016 at 6:53 PM
Edited Apr 5, 2016 at 1:10 AM
It occurs to me that I may have identified a future plugin that's ridiculously over my head to implement. Could be just the thing to exercise my nascent C# programming skills on. Time is in exquisitely short supply at the moment, though, between working on a graduate degree and running an independent consulting business. If I need to roll up my sleeves--farther, I'm willing to do that. Just let me know which path I'm headed for.

-Leland
Apr 5, 2016 at 1:09 AM
Edited Apr 5, 2016 at 1:16 AM
There is a simple method to determine if a point is inside of a 2D polygon (Method 2):

http://paulbourke.net/geometry/polygonmesh/#insidepoly

Add all angles defined by the point in question and the endpoints of each polygon segment. A sum of 2pi means inside [or on an edge]. A sum of 0 means outside. Someone on StackOverflow said they tested it at world scale. I see that an additional computation is needed to convert to great circle angle sides, otherwise an inside point's angles won't quite add up to 2pi.

This method would involve parsing through the records of a table and checking each one's lat/long point against the polygon's vertices. This is sure to be a slow process, though a pre-screen could probably speed it up, such as whether a record's point lies within the Max and Min Lat/Longs of the polygon.

-Leland
Coordinator
Apr 17, 2016 at 10:21 AM
Hi Leland,

I'm not sure what you need.

Do you have two layers? One with polygons and one with points and you want to know which points are inside which polygon?
If so you can have a look at the toolbox. It should be at the right of MW5, if not you might need to load it using the plug-ins menu.
Have a look at the 'Spatial Query'-tool or the Overlay-tool.

If this is not what you need, could you explain more what you do need?

Regards,

Paul
Apr 21, 2016 at 8:51 PM
The Overlay tool was just the ticket, Paul. By the way, the [Ctrl+Run] button feature that allows recursive combinations is brilliant!
Do you have two layers? One with polygons and one with points and you want to know which points are inside which polygon?
Yes, I have a layer with a polygon and a layer with points and am trying to filter the points that are inside of a given polygon. The next step is to add more polygons to the polygon layer and see if I can select just one of them to use as a filter or if the Overlay tool requires each polygon to be on a separate layer.

I tried to export the resultant table but only see a shx format export option. Can I easily export to XML or CSV?

Thanks X 10^6,
-Leland
Marked as answer by LlndPrkr on 4/21/2016 at 2:05 PM
Apr 21, 2016 at 8:58 PM
I re-read your question and it raises the possibility of a potentially more ideal arrangement: Is it possible to have multiple named polygons on a single layer and merge that with a layer of points to produce a table where each record is the point data plus a field for which polygon it lies in?

If so, I might be able to use the polygon layer as a master dashboard to produce a master table or a sub-table based on one or more polygons.

Thanks for the help so far. Any guidance is appreciated. -Leland
Coordinator
Apr 25, 2016 at 10:24 AM
Hi Leland,

At this moment what you ask is not possible. It could be added as a new tool.
I created https://mapwindow.atlassian.net/browse/TOOLS-39 for this.

About exporting data. I created https://mapwindow.atlassian.net/browse/CORE-167 for this.
As a workaround you can open the dbf-file in Excel or LibreOffice and save it as csv.
Don't save in Excel or LibreOffice the dbf-file your data will be corrupted.

Regards,

Paul
May 2, 2016 at 2:38 AM
Those two features are a hopeful future solution, Paul, and are bound to be valuable functions when they're done and ready for prime time. Thanks for creating the tracking pages.

In the meantime, is there a way to copy the query results to the clipboard? I tried this but the records and fields would only highlight and nothing transferred to the clipboard on [Ctrl+C].

-Leland