Prioritising polygons in QGIS
I just created a layer in which I hand drew a lot of polygons.
Now I want to fill out the Attribute table through commands since it will save me a bunch of time.
Therefore, I calculated the area of each polygon using $area/10000
to have the size in ha
.
I want to prioritize each area
- above 10 ha as Prio 1
- each below 1 ha as Prio 3
- each in between as Prio 2
Does anyone have a smart solution to the problem?
My closest approach is: IF ("Size ha" > 5, 1, 2)
That however still leaves me with having to distinguish the areas of Prio 2 to Prio 3 manually.
qgis polygon attribute-table command-line
New contributor
add a comment |
I just created a layer in which I hand drew a lot of polygons.
Now I want to fill out the Attribute table through commands since it will save me a bunch of time.
Therefore, I calculated the area of each polygon using $area/10000
to have the size in ha
.
I want to prioritize each area
- above 10 ha as Prio 1
- each below 1 ha as Prio 3
- each in between as Prio 2
Does anyone have a smart solution to the problem?
My closest approach is: IF ("Size ha" > 5, 1, 2)
That however still leaves me with having to distinguish the areas of Prio 2 to Prio 3 manually.
qgis polygon attribute-table command-line
New contributor
Just a general annotation: The expamples given on the different tools in the field calculator are quite useful to picture, how the tools work.
– Erik
19 hours ago
add a comment |
I just created a layer in which I hand drew a lot of polygons.
Now I want to fill out the Attribute table through commands since it will save me a bunch of time.
Therefore, I calculated the area of each polygon using $area/10000
to have the size in ha
.
I want to prioritize each area
- above 10 ha as Prio 1
- each below 1 ha as Prio 3
- each in between as Prio 2
Does anyone have a smart solution to the problem?
My closest approach is: IF ("Size ha" > 5, 1, 2)
That however still leaves me with having to distinguish the areas of Prio 2 to Prio 3 manually.
qgis polygon attribute-table command-line
New contributor
I just created a layer in which I hand drew a lot of polygons.
Now I want to fill out the Attribute table through commands since it will save me a bunch of time.
Therefore, I calculated the area of each polygon using $area/10000
to have the size in ha
.
I want to prioritize each area
- above 10 ha as Prio 1
- each below 1 ha as Prio 3
- each in between as Prio 2
Does anyone have a smart solution to the problem?
My closest approach is: IF ("Size ha" > 5, 1, 2)
That however still leaves me with having to distinguish the areas of Prio 2 to Prio 3 manually.
qgis polygon attribute-table command-line
qgis polygon attribute-table command-line
New contributor
New contributor
edited 18 hours ago
nmtoken
7,95642766
7,95642766
New contributor
asked 19 hours ago
Philip GatzlaffPhilip Gatzlaff
61
61
New contributor
New contributor
Just a general annotation: The expamples given on the different tools in the field calculator are quite useful to picture, how the tools work.
– Erik
19 hours ago
add a comment |
Just a general annotation: The expamples given on the different tools in the field calculator are quite useful to picture, how the tools work.
– Erik
19 hours ago
Just a general annotation: The expamples given on the different tools in the field calculator are quite useful to picture, how the tools work.
– Erik
19 hours ago
Just a general annotation: The expamples given on the different tools in the field calculator are quite useful to picture, how the tools work.
– Erik
19 hours ago
add a comment |
2 Answers
2
active
oldest
votes
This should work
if($area/10000 > 10,1,if($area/10000 < 1,3,2))
Just a capsuled if-condition, first checking for areas greater 10 ha, then checking for those smaller than 1 ha, then giving everything else prio 2.
add a comment |
CASE
WHEN "Size ha" >= 10 THEN 'Prio 1'
WHEN "Size ha" > 1 AND "Size ha" < 10 THEN 'Prio 2'
WHEN "Size ha" <= 1 THEN 'Prio 3'
END
Or as was provided by @Erik, the upper formula can be rewritten as
if("Size ha" >= 10, 'Prio 1', if("Size ha" <= 1, 'Prio 3', 'Prio 2'))
Reference:
- Expressions | Conditionals
Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!
– Philip Gatzlaff
19 hours ago
Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.
– Erik
19 hours ago
1
@Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)
– Erik
19 hours ago
1
@Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)
– Taras
19 hours ago
1
Just create a new column and fill it with CASE formula.
– Taras
19 hours ago
|
show 3 more comments
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Philip Gatzlaff is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f313607%2fprioritising-polygons-in-qgis%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This should work
if($area/10000 > 10,1,if($area/10000 < 1,3,2))
Just a capsuled if-condition, first checking for areas greater 10 ha, then checking for those smaller than 1 ha, then giving everything else prio 2.
add a comment |
This should work
if($area/10000 > 10,1,if($area/10000 < 1,3,2))
Just a capsuled if-condition, first checking for areas greater 10 ha, then checking for those smaller than 1 ha, then giving everything else prio 2.
add a comment |
This should work
if($area/10000 > 10,1,if($area/10000 < 1,3,2))
Just a capsuled if-condition, first checking for areas greater 10 ha, then checking for those smaller than 1 ha, then giving everything else prio 2.
This should work
if($area/10000 > 10,1,if($area/10000 < 1,3,2))
Just a capsuled if-condition, first checking for areas greater 10 ha, then checking for those smaller than 1 ha, then giving everything else prio 2.
answered 19 hours ago
ErikErik
3,273322
3,273322
add a comment |
add a comment |
CASE
WHEN "Size ha" >= 10 THEN 'Prio 1'
WHEN "Size ha" > 1 AND "Size ha" < 10 THEN 'Prio 2'
WHEN "Size ha" <= 1 THEN 'Prio 3'
END
Or as was provided by @Erik, the upper formula can be rewritten as
if("Size ha" >= 10, 'Prio 1', if("Size ha" <= 1, 'Prio 3', 'Prio 2'))
Reference:
- Expressions | Conditionals
Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!
– Philip Gatzlaff
19 hours ago
Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.
– Erik
19 hours ago
1
@Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)
– Erik
19 hours ago
1
@Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)
– Taras
19 hours ago
1
Just create a new column and fill it with CASE formula.
– Taras
19 hours ago
|
show 3 more comments
CASE
WHEN "Size ha" >= 10 THEN 'Prio 1'
WHEN "Size ha" > 1 AND "Size ha" < 10 THEN 'Prio 2'
WHEN "Size ha" <= 1 THEN 'Prio 3'
END
Or as was provided by @Erik, the upper formula can be rewritten as
if("Size ha" >= 10, 'Prio 1', if("Size ha" <= 1, 'Prio 3', 'Prio 2'))
Reference:
- Expressions | Conditionals
Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!
– Philip Gatzlaff
19 hours ago
Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.
– Erik
19 hours ago
1
@Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)
– Erik
19 hours ago
1
@Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)
– Taras
19 hours ago
1
Just create a new column and fill it with CASE formula.
– Taras
19 hours ago
|
show 3 more comments
CASE
WHEN "Size ha" >= 10 THEN 'Prio 1'
WHEN "Size ha" > 1 AND "Size ha" < 10 THEN 'Prio 2'
WHEN "Size ha" <= 1 THEN 'Prio 3'
END
Or as was provided by @Erik, the upper formula can be rewritten as
if("Size ha" >= 10, 'Prio 1', if("Size ha" <= 1, 'Prio 3', 'Prio 2'))
Reference:
- Expressions | Conditionals
CASE
WHEN "Size ha" >= 10 THEN 'Prio 1'
WHEN "Size ha" > 1 AND "Size ha" < 10 THEN 'Prio 2'
WHEN "Size ha" <= 1 THEN 'Prio 3'
END
Or as was provided by @Erik, the upper formula can be rewritten as
if("Size ha" >= 10, 'Prio 1', if("Size ha" <= 1, 'Prio 3', 'Prio 2'))
Reference:
- Expressions | Conditionals
edited 18 hours ago
answered 19 hours ago
TarasTaras
2,1672624
2,1672624
Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!
– Philip Gatzlaff
19 hours ago
Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.
– Erik
19 hours ago
1
@Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)
– Erik
19 hours ago
1
@Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)
– Taras
19 hours ago
1
Just create a new column and fill it with CASE formula.
– Taras
19 hours ago
|
show 3 more comments
Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!
– Philip Gatzlaff
19 hours ago
Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.
– Erik
19 hours ago
1
@Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)
– Erik
19 hours ago
1
@Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)
– Taras
19 hours ago
1
Just create a new column and fill it with CASE formula.
– Taras
19 hours ago
Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!
– Philip Gatzlaff
19 hours ago
Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!
– Philip Gatzlaff
19 hours ago
Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.
– Erik
19 hours ago
Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.
– Erik
19 hours ago
1
1
@Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)
– Erik
19 hours ago
@Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)
– Erik
19 hours ago
1
1
@Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)
– Taras
19 hours ago
@Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)
– Taras
19 hours ago
1
1
Just create a new column and fill it with CASE formula.
– Taras
19 hours ago
Just create a new column and fill it with CASE formula.
– Taras
19 hours ago
|
show 3 more comments
Philip Gatzlaff is a new contributor. Be nice, and check out our Code of Conduct.
Philip Gatzlaff is a new contributor. Be nice, and check out our Code of Conduct.
Philip Gatzlaff is a new contributor. Be nice, and check out our Code of Conduct.
Philip Gatzlaff is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f313607%2fprioritising-polygons-in-qgis%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Just a general annotation: The expamples given on the different tools in the field calculator are quite useful to picture, how the tools work.
– Erik
19 hours ago