30

You miss a minus sign before where and the select is not necessary, so it should be: ogr2ogr -where ID="1" outfile.shp infile.shp or if you have to do more complex query on your input data: ogr2ogr -sql "SELECT * FROM infile WHERE ID='1'" outfile.shp infile.shp If ID is a field of Integer type, substitute ID='1' with ID=1. Notes: -f "ESRI Shapefile" is ...


26

Nowadays (QGIS v3.x) Get the layer reference: layer = iface.activeLayer() Select features by expression: layer.selectByExpression( "\"ogc_fid\"=482" ) Before QGIS 2.16 Follow these steps: Get the layer reference: cLayer = iface.mapCanvas().currentLayer() Get a featureIterator from an expression: expr = QgsExpression( "\"ogc_fid\"=482" ) it = cLayer....


24

The simple trick to select only Integer values, is to use the following syntax: Mod(Round("ELEVATION", 0)*10, 10)=0 This Multiplication by 10, makes all the values Integer, and then we select only those which are multiples of 10. In case you wish to select Multiples of some other number, just multiply 10 by the interval. To get contours at 5 m intervals, ...


23

You can achieve this with a very simple model if you have ArcGIS 10.0 or higher. Create a model with Feature Iterator where the group by field is the attribute you wish to select by then send the output to the copy features tool using inline substitution to ensure a unique file name. The model is shown below:


22

You can also use the SQL IN operator "City Name" IN ('ROME','NAPLES')


21

A more elegant solution is: "Classes" in ('14','15',....)


19

This is a common error that I have run across, and I am pretty sure it is related to attempting to run the selection against a raw featureclass/shapefile output, as opposed to the "layer" representation of the featureclass/shapefile. For example: You cannot select features from a shapefile without using ArcMap, but once you load the shapefile into ArcMap (...


19

You can loop over the iterator and get the .id() for every feature in it: with edit(layer): # build a request to filter the features based on an attribute request = QgsFeatureRequest().setFilterExpression('"DN" != 3') # we don't need attributes or geometry, skip them to minimize overhead. # these lines are not strictly required but improve ...


17

To calculate the length in characters of a string expression use CHAR_LENGTH(string_exp) Field name delimiters for file geodatabase is double quotes (not square brackets). So this should work: CHAR_LENGTH(“ColumnName“) > 5 Here is a SQL reference for query expressions used in ArcGIS.


17

Using the Select by Attributes tool, you could enter the following SQL query to select all features with less than 5 characters in the ZIP field: CHAR_LENGTH("ZIP") < 5


16

I do not have access to ArcMap 10, only 9.3, but I expect that it won't be very different from this. You can create a simple script in Python, that checks your attribute field for different values, and then, for each of them runs a SELECT operation to your original Shapefile. If you are not familiar with python scripting, all you need to do is open you ...


16

Have you tried paoText is NULL or paoText is not NULL


15

I think you need to use the following instead: "GRIDCODE" >= 10 AND "GRIDCODE" < 15 You need to switch the => operators and specify again the attribute field for the second term (i.e. < 15).


14

Without knowing what your data looks like, the general syntax you need to insert into the select by attributes window is: [FIELD_1] IS NULL OR [FIELD_2] IS NULL OR [FIELD_3] IS NULL and so on for as many fields as you have to work with. For reference the full query would be: SELECT * FROM [TABLE_NAME] WHERE [FIELD_1] IS NULL OR [FIELD_2] IS NULL OR [...


14

Very nice use case for yet another handy QGIS feature: Layer actions! Here the steps to configure your layer action: Open your layer Properties dialog. Click on menu Actions. Click on the green cross to add an action. Fill the dialog inputs as indicated in the following picture. You can Copy & Paste this couple of lines of code into the 'Action Text' ...


13

You would select the rows which are NULL (sounds like you have done that) then simply run the calculate field tool. Right Click the field you want to modify (while objects are selected) Then input your value "newvalue" NOTE: 1. if you don't have a selection this will work on "ALL" rows in your table! 2. Double quotes in this area on your text/date ...


12

How about "ONScode" != '17UB' != means "not equal to".


11

You would need to break up your selection statement into two separate parts: "Classes" = '14' OR "Classes" = '07' Edit: Changed from AND to OR, since as noted in the comments, AND cannot work in this situation.


11

The number values in your example query have quotation marks around them, so it looks like the problem is that your house numbers are stored as strings and not as numbers. You can check by right-clicking the field heading and clicking Properties. If the type is String, you'll need to create a new House Number field of the Integer type. Use the Field ...


11

There are two possibilities when you want to select several value. The first is to use the OR operator : "Parametro" = 'alfa-Hexaclorociclohexano' OR "Parametro" = 'beta-Hexaclorociclohexano' OR "Parametro" = 'delta-Hexaclorociclohexano' OR "Parametro" = 'gamma-Hexaclorociclohexano' You need to repeat the field name each time (this also work if you want ...


10

Your queries should follow the SQL format discussed here. For what you're looking for, you can use something like this: "Some_Field" LIKE 'A%' The % is a wild card, so this would return records that have values in "Some_Field" that start with 'A'.


10

Use a Feature Selection iterator in ModelBuilder. You can specify the field you want the selection to be grouped by (your field containing the unique values). It will iterate over your entire feature class, creating a selection layer from each unique value. You can then add more tools for the rest of your workflow.


10

Follow these 5 steps in the QGIS Python console: Get the layer reference (I assume the layer is at the top of the ToC): l = iface.mapCanvas().layers()[0] Get a featureIterator from an expression: expr = QgsExpression( "\"EXCHANGE_1141_CODE\"='IH'" ) it = l.getFeatures( QgsFeatureRequest( expr ) ) Build a list of feature Ids from the result obtained in 2....


9

I used @AlexandreNeto's script and updated it for ArcGIS 10.x users. Mainly you now have to import "arcpy" instead of "arcgisscripting": # Script created to separate one shapefile in multiple ones by one specific # attribute # Example for a Inputfile called "my_shapefile" and a field called "my_attribute" import arcpy #Set Input Output variables inputFile ...


9

Here is another query option. It largely does the same as the answers listed above but is (in my opinion) a little bit easier to customise for different scenarios. To display any contour divisible by 10 Floor(Elevation/10)=Elevation/10 To display any contour divisible by 50 Floor(Elevation/50)=Elevation/50 To display half metre contours Floor(...


8

You can use Substring("fieldname", start, length) to mimick, left(), right() and mid() functions when querying a fgdb. Left and Mid are obvious. To extract the right 2 characters would be Substring("fieldname", char_length("fieldname") - 1), 2). Column numbers are 1-based.


8

Iterators would definitely help you here. Just in case you would need to export the feature classes on disk first, I attach the image I've created recently. In case you don't want to bother with the model building, consider using Split by Attributes tool already compiled and available for use as a GP tool that does exactly the same thing as the model above.


8

If your tool supports it, use the modulo operator. e.g. value % 5 = 0 ... all features with a value that divides by five without a remainder.


8

The information you are looking for is hidden in a panel that is collapsed/minimized on the right-hand side of the dialog. Here's how you can access it:


8

You are doing fine, but just need to go to next step. Tick on Save only selected features.


Only top voted, non community-wiki answers of a minimum length are eligible