1

I am trying to use select by expression to query lines that contain certain attributes and that there geometry touch. In other words are connected or neighbour each other.

I tried a query such as this. My attribution might not make sense but I just need the syntax correct.

"isDiscouraged" = 't' AND touches("roadclass" = 'ramp')

or

"Links that have this attribute" AND Touch "links that have this attribute"

So I want to find links that contain the attribute isdiscouraged = t that are connected to links with this other attribute roadclass = ramp. Is this possible?

My above query is invalid but lays out what I'm looking for. Any ideas how to tweek it to make it work.

I know its kind of a more spatial query combined with attribute query but can't get it to work!

1

But your features are all in the same layer? if yes you can't do a spatial query on the same layer. You need to duplicate the layer.

I suggest to do this:

layer_1->filter->"isdiscouraged" = 't'

copy_of_layer_1->filter-> "roadclass" = 'ramp'

Spatial query layer_1 touchs copy_of_layer_1

If you use postgresql and postgis you can do this with just one query

SELECT foo1.* FROM
(SELECT * FROM layer_1 WHERE isdiscouraged = 't') as foo1
(SELECT * FROM layer_1 WHERE roadclass = 'ramp') as foo2
WHERE st_touches(foo1.geom, foo2.geom);

I suggest to read what touches mean, beacause probably intersection is more usefull for you

  • Thanks! Im going to look into running the query in PostgreSQL. I thought of the spatial query idea but my layer contains over 52 million links and to run those queries would take hours or days haha. Im talking to a developer to help me run this through our database. I appreciate the help! – Andrew Jul 16 '15 at 12:54

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.