Wednesday 10 June 2015

query - Filter contour lines in QGIS


I have a shapefile of contour lines, with an ALTITUDE attribute with the height ASL in metres. The source data is in 0.5m intervals, but I'd like to filter it down so I get contour lines at (for eg.) 5m intervals.


I tried doing a query on the layer using "ALTITUDE" % 5 = 0, which almost worked except I get two contour lines where I would expect one - I'm guessing this is because % is an integer operation so 245.5 % 5 and 245.0 % 5 both = 0?


Is there a better way to filter for 5m (or some other interval, say 1m or 2.5m) data?



Answer



Multiply everything with 10 to get rid of your first decimal place:




("ALTITUDE"*10) % (5*10) = 0



This should work accordingly with any other figure.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...