I'm trying to style some OSM data such that short fences, walls, etc just don't render. I only want to display barriers over some certain length. I've tried this rule,

tags LIKE '%barrier%' AND ($length > 100)

and quite a few variations on it, finally getting

tags LIKE '%barrier%' AND $length > 0.001

to do about what I want. Clearly, I don't know what units this is measuring in. It was awkward getting it to work though because while the "test" button next to the formula always gave me no results, the actual map stopped drawing the shorter fences like I wanted.

test button not working

Indeed, the test button doesn't seem to want to work with any length attribute, as even

tags LIKE '%barrier%' AND $length != 0 

returns "no results". So I guess my question now is: Am I doing something wrong, or is this a bug?

  • Which version of QGIS? – Nathan W Dec 20 '12 at 6:41
  • 2
    Seems to work currently on my end. What projection are you using? – Nathan W Dec 20 '12 at 6:47
  • The OSM data is in EPSG:4326 - WGS 84 and reprojected on the fly to EPSG: 3735 NAD83 Ohio South(ftUS) – Nate Wessel Dec 20 '12 at 15:08
  • On the fly reprojection does not affect the measurements in this case. – underdark Dec 20 '12 at 15:58
  • QGIS version 1.8.0-Lisboa – Nate Wessel Dec 20 '12 at 18:16

Add a new column and therein calculate the lenth. Then adapt the rules to use the values from the column instead of calculating it in the rule.

  • I can't find a way to do that with an OSM file without saving it as a shapefile. The edit button is greyed out :-/ – Nate Wessel Dec 20 '12 at 15:09
  • My bad! Didn't know that OSM-data are different from shapes. – GR_ Dec 20 '12 at 15:13
  • @NateWessel Would it be possible to use the shapefile extracts of your OSM data? Or do you really need to use the OSM format? – R.K. Dec 22 '12 at 4:12
  • When I save the OSM as a shapefile it cuts off the tag field, probably at around 100 characters. I don't see a way to change that, but maybe if I only did it for the features I was looking for it would be ok since I'm symbolizing them all the same way anyway. Yes. Actually, I think that will work for me! Though it's less than an ideal solution. – Nate Wessel Dec 23 '12 at 17:18

Does the layer CRS use meter units? If you write a rule like

tags LIKE '%barrier%' AND ($length > 100)

and the CRS is e.g. WGS84 in degrees, you would be asking for lines that are longer than 100 degrees. Try to change to

tags LIKE '%barrier%' AND ($length > 0.001)

ad your update:

Am I doing something wrong, or is this a bug?

This seems to be a bug related to the fact that you are working with an OSM layer. It should be tested and reported.

  • That works!! But not totally. Editing my original question with the new situation... – Nate Wessel Dec 20 '12 at 15:10

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.