I have a point shapefile in QGIS (3.30.2) containing more than 2000 points. I selected about 150 of these points based on a special criteria.
I need to create a separate shapefile with only these 200 points. I usually select the desired rows in attribute table manually and use 'Export > Save selected features as >'. Considering the high number of points (150), is there an easier way to select these rows?
Update: I don't think it is possible to use 'select by expression', because they do not have a value greater or less than a specific amount. They are not categorized in any way.
Each point has a number associated to it and I selected them based on their photo, which had a particular characteristic, and the photo was inside a link, in one of the fields of the attribute table.
So, the only way, in my opinion, is to write the number of all these 150 point in an expression and use 'OR' or 'AND' to select them all. Is that correct? Which expression would use less time?
-
1You mean like using "select by expression" to select all points with population "greater than 1000" or something? That's what "select by expression" (button in attribute table toolbar) does.Spacedman– Spacedman2023年11月13日 14:38:21 +00:00Commented Nov 13, 2023 at 14:38
-
I updated the question.Paris– Paris2023年11月13日 14:54:50 +00:00Commented Nov 13, 2023 at 14:54
-
2if you can't generalize your selection decision and must look for these 150 photos one by one to decide ... you are doing it the best way to my knwoledge. But you may be inspired to look your decision making and optimize it a bitMaximilien jaffrès– Maximilien jaffrès2023年11月13日 15:15:23 +00:00Commented Nov 13, 2023 at 15:15
-
4Writing an expression with 150 clauses is going to be a huge amount of work and will take much longer than just manually selecting them. However, once they are selected, use Field Calculator to calculate a new field to signify that they are selected (for example, either an integer 1 or 0, a boolean field, or a text string 'selected'). That way you have a permanent record of which you selected and this field can then be used in a filter later.Matt– Matt2023年11月13日 15:34:36 +00:00Commented Nov 13, 2023 at 15:34
-
1If you can put those 150 numbers in a non-spatial table then you can (possibly) do a "join" based on an expression on the source table that gets the number from the attribute and then selects based on the success/fail status of the join. Is there any chance you could expand on this a bit more with maybe a screenshot of the attribute table of your source layer and show what part of the attribute decides if a point is included or now?Spacedman– Spacedman2023年11月13日 15:44:20 +00:00Commented Nov 13, 2023 at 15:44
2 Answers 2
Best way to use Select by expression
to select, based on an arbitrary array of numbers from the attribute field foto
, is to use this expression:
"foto" in (84,46,78,97,18)
You can't permanently save a seletion (unlike in graphic software) but as mentioned by @Matt, you can create a new field selected
with the expression is_selected()
that returns true for all selected features.
-
1Thanks. I guess this would be the best way.Paris– Paris2023年11月14日 07:48:06 +00:00Commented Nov 14, 2023 at 7:48
If you hace already selected your desired objects, you can use the Extract by expression
tool. Simply check the Selected objects
checkbox and put a 1 in the Expression
box.
enter image description here
Explore related questions
See similar questions with these tags.