Monday 29 May 2017

sql - Using QGIS to Select by Expression?


A basic QGIS 2.2.0-Valmiera, Select By Expression - Field Calculator question.


Introduction


I am a geologist searching through a geological database (see attached figure). I have a shapefile and associated attribute file of which I would like to select certain records within a field to make as new shapefile layer.


Task/method


I wish to search the 'GEOLHIST' and select Permian lithologies using the field calculator. Subsequently I shall Save Selection As. I have tried using the following script unsuccessfully.


"GEOLHIST" 

IS 'Early Carboniferous to Early Permian'
OR 'Early Permian'
OR 'Early Permian to Late Carboniferous'
OR 'Early Permian to Late Permian'
OR 'Late Carboniferous to Early Permian'
OR 'Late Carboniferous to Permian'
OR 'Late Permian'
OR 'Late Permian to Permian' 'Permian'
OR 'Permian to Early Permian'


Question


What script can I use to select the above records?


Discussion


'GEOLHIST' IS 'Permian'

This script works. I have looked at the other OPERATORS (AND OR IS LIKE) and CONDITIONALS and have not figured out how to achieve my task.


Geological Attribute Table


@Nathan provided a working script, see attached figure.


I was not aware of the SQL operator in or the method of bracketing. This technique will be most helpful in the future.


"GEOLHIST" IN 

(
'Carboniferous to Early Permian'
, 'Early Permian'
, 'Early Permian to Late Carboniferous'
, 'Early Permian to Late Permian'
, 'Late Carboniferous to Early Permian'
, 'Permian'
, 'Permian to Early Permian'
)


GEOLHIST SQL for multiple record success




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...