0

GOAL: I'm trying to filter all the 1's in a spatial boolean operation in Qspatialite, the spatialite plugin for QGIS.

ATTEMPTED SOLUTION: My solution is to perform the boolean query first, export the resulting table AS a table second, then query THAT table for all the 1's, third.

PROB W/ SOLUTION: Problem is, column to be filtered has a header that is in itself a function (i.e., "within(geom 1, geom 2)"). Thus, the header cannot be called in the command dialog as a simple string, because it inevitably becomes a command/function.

This is what I ran:

SELECT Towns.name, Schools.name, within(Schools.geom, Towns.geom) from Towns, Schools

So, within(Schools.geom,Towns.geom) becomes the table header, which I need to filter for 1s.

Any ideas/suggestions?

0

Could you just use an alias, and subsequently reference the alias (in the example below, InTowns)?

SELECT Towns.name, Schools.name within(Schools.geom, Towns.geom) AS InTowns from Towns, Schools

As an alternative, you could do:

SELECT Towns.name, Schools.name FROM Towns, Schools WHERE Within(Schools.geom, Towns.geom)

In the latter case there would be no filtering to do, as by default you would only have records where the schools are within the towns.

| improve this answer | |
  • I already went straight ahead with your second suggestion. Worked perfectly! – wearashirt May 21 '15 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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