1

I have two layers in MapInfo (points and polygons). I need to select points which fall within polygons where the income > 1500

I tryed this one but not working: http://www.sgsi.com/MIUserGroup/imgs/sql1.jpg

I also tryed this SQL code but doesn't work: points.Obj Within polygon.Obj where income > 1500

Any idea?

1
  • You seem to be going about this the right way, which suggests that there is something missing in the files your working with. Can you check the Polygon file to make sure that has income data in it? The first step of the query is a selection of those polygons meeting the >1500 criteria - so that is critical for the query. If the Polygon file contains income data, check the formatting of it - you're using a numerical value, so make sure the data is in that format. ALWAYS (!) break the problem down into a logical order. Commented Jan 26, 2015 at 6:12

1 Answer 1

3

The where condition you are looking for is:

points.Obj Within polygon.Obj AND polygon.income > 1500

You can also solve the problem by using a sub select query instead of a join query. Here is how to fill in the details in the SQL Select dialog:

Select: *

From: POINTS

Where: OBJ Within Any (Select OBJ From POLYGON Where INCOME > 1500)

Or in a Select expression it would look like this:

Select *
From POINTS
Where OBJ Within Any (Select OBJ From POLYGON Where INCOME > 1500)
4
  • Thank u! It works fine :) But when i export to kml the selected and saved query tab, it has no attribute data. How can i export kml or shp with attribute data?
    – mrbandy
    Commented Jan 27, 2015 at 7:38
  • This is not an answer and so I will convert it to a comment on the answer to which I think it relates. You make no mention of KML in your original question so if you have a new one please post it instead of changing the scope of your question after it has been answered. The Tour should make our protocols a little clearer.
    – PolyGeo
    Commented Jan 27, 2015 at 8:18
  • Just a note that subselects in MapInfo are horrendously slow, so stick with the first solution.
    – ndawson
    Commented Jan 27, 2015 at 21:02
  • Very Much appreciated. It helps a lot.Thanks Peter
    – Imtiaz
    Commented Jan 6, 2017 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.