Use intersection in field calculator
Clash Royale CLAN TAG#URR8PPP
I want to use the tool intersects in the field calculator. If the condition is true, I want to set a result field to a specific number. The field calculator doesn't accept my expression but I can not find the reason for the error. Can you please help me.
CASE
WHEN intersects('layer1', 'layer2') = true THEN 1
WHEN intersects('layer1', 'layer3') = true THEN 2
END
the error says:
syntax error, unexpected NUMBER_INT, expecting WHEN or ELSE or END
syntax error, unexpected END, expecting $end
I work with QGIS 3.4 (Madeira)
qgis field-calculator qgis-3 intersection
add a comment |
I want to use the tool intersects in the field calculator. If the condition is true, I want to set a result field to a specific number. The field calculator doesn't accept my expression but I can not find the reason for the error. Can you please help me.
CASE
WHEN intersects('layer1', 'layer2') = true THEN 1
WHEN intersects('layer1', 'layer3') = true THEN 2
END
the error says:
syntax error, unexpected NUMBER_INT, expecting WHEN or ELSE or END
syntax error, unexpected END, expecting $end
I work with QGIS 3.4 (Madeira)
qgis field-calculator qgis-3 intersection
add a comment |
I want to use the tool intersects in the field calculator. If the condition is true, I want to set a result field to a specific number. The field calculator doesn't accept my expression but I can not find the reason for the error. Can you please help me.
CASE
WHEN intersects('layer1', 'layer2') = true THEN 1
WHEN intersects('layer1', 'layer3') = true THEN 2
END
the error says:
syntax error, unexpected NUMBER_INT, expecting WHEN or ELSE or END
syntax error, unexpected END, expecting $end
I work with QGIS 3.4 (Madeira)
qgis field-calculator qgis-3 intersection
I want to use the tool intersects in the field calculator. If the condition is true, I want to set a result field to a specific number. The field calculator doesn't accept my expression but I can not find the reason for the error. Can you please help me.
CASE
WHEN intersects('layer1', 'layer2') = true THEN 1
WHEN intersects('layer1', 'layer3') = true THEN 2
END
the error says:
syntax error, unexpected NUMBER_INT, expecting WHEN or ELSE or END
syntax error, unexpected END, expecting $end
I work with QGIS 3.4 (Madeira)
qgis field-calculator qgis-3 intersection
qgis field-calculator qgis-3 intersection
edited Feb 21 at 17:24
underdark♦
68.9k13178345
68.9k13178345
asked Feb 21 at 15:52
L.EidenL.Eiden
161
161
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The intersects
function requires two geometries (not layers) as input requirements as described in the help section of the field calculator:
intersects(geometry a, geometry b)
Tests whether a geometry intersects another. Returns true if the geometries spatially intersect (share any portion of space) and false if they do not.
If you want to use layer names, install the refFunctions plugin which adds more functions to the field calculator such as:
geomintersects(targetLayer,targetField)
Retrieve target field value when source feature intersects target feature in target layer.
Assuming you are using the field calculator on layer1
, you could use something like the following:
CASE
WHEN geomintersects('layer2', 'any_layer2_FieldName') THEN 1
WHEN geomintersects('layer3', 'any_layer3_FieldName') THEN 2
END
I want to change always the same field (from the same layer). My layer1 contains different polygons, wich represent the location of buildings. With the intersect operation I want to change always the field "Geb_Nutz" (layer1), wich shows the kind of use for the building. For all the buildings, that intersect layer1 and layer2, I want to set "Geb_Nutz" to 1. For all the buildings, that intersect layer1 and layer3, I want to set "Geb_Nutz" to 2. I tried the following operation, but it still doesn't work.
– L.Eiden
Feb 22 at 12:16
CASE WHEN geomintersects('layer2',"Geb_Nutz") THEN 1 WHEN geomintersects('layer3',"Geb_Nutz") THEN 2 END
– L.Eiden
Feb 22 at 12:17
If you want to change the field "Geb_Nutz" then you need to provide any field name from layer2 and layer3 for the expression. Do not use "Geb_Nutz" because that is the field you want to change. So select layer1, go to the field calculator, select to update your chosen field and use the expression:CASE WHEN geomintersects('layer2', 'layer2_field') THEN 1 WHEN geomintersects('layer3', 'layer3_field') THEN 2 END
– Joseph
Feb 22 at 12:22
add a comment |
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
);
);
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%2f313091%2fuse-intersection-in-field-calculator%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The intersects
function requires two geometries (not layers) as input requirements as described in the help section of the field calculator:
intersects(geometry a, geometry b)
Tests whether a geometry intersects another. Returns true if the geometries spatially intersect (share any portion of space) and false if they do not.
If you want to use layer names, install the refFunctions plugin which adds more functions to the field calculator such as:
geomintersects(targetLayer,targetField)
Retrieve target field value when source feature intersects target feature in target layer.
Assuming you are using the field calculator on layer1
, you could use something like the following:
CASE
WHEN geomintersects('layer2', 'any_layer2_FieldName') THEN 1
WHEN geomintersects('layer3', 'any_layer3_FieldName') THEN 2
END
I want to change always the same field (from the same layer). My layer1 contains different polygons, wich represent the location of buildings. With the intersect operation I want to change always the field "Geb_Nutz" (layer1), wich shows the kind of use for the building. For all the buildings, that intersect layer1 and layer2, I want to set "Geb_Nutz" to 1. For all the buildings, that intersect layer1 and layer3, I want to set "Geb_Nutz" to 2. I tried the following operation, but it still doesn't work.
– L.Eiden
Feb 22 at 12:16
CASE WHEN geomintersects('layer2',"Geb_Nutz") THEN 1 WHEN geomintersects('layer3',"Geb_Nutz") THEN 2 END
– L.Eiden
Feb 22 at 12:17
If you want to change the field "Geb_Nutz" then you need to provide any field name from layer2 and layer3 for the expression. Do not use "Geb_Nutz" because that is the field you want to change. So select layer1, go to the field calculator, select to update your chosen field and use the expression:CASE WHEN geomintersects('layer2', 'layer2_field') THEN 1 WHEN geomintersects('layer3', 'layer3_field') THEN 2 END
– Joseph
Feb 22 at 12:22
add a comment |
The intersects
function requires two geometries (not layers) as input requirements as described in the help section of the field calculator:
intersects(geometry a, geometry b)
Tests whether a geometry intersects another. Returns true if the geometries spatially intersect (share any portion of space) and false if they do not.
If you want to use layer names, install the refFunctions plugin which adds more functions to the field calculator such as:
geomintersects(targetLayer,targetField)
Retrieve target field value when source feature intersects target feature in target layer.
Assuming you are using the field calculator on layer1
, you could use something like the following:
CASE
WHEN geomintersects('layer2', 'any_layer2_FieldName') THEN 1
WHEN geomintersects('layer3', 'any_layer3_FieldName') THEN 2
END
I want to change always the same field (from the same layer). My layer1 contains different polygons, wich represent the location of buildings. With the intersect operation I want to change always the field "Geb_Nutz" (layer1), wich shows the kind of use for the building. For all the buildings, that intersect layer1 and layer2, I want to set "Geb_Nutz" to 1. For all the buildings, that intersect layer1 and layer3, I want to set "Geb_Nutz" to 2. I tried the following operation, but it still doesn't work.
– L.Eiden
Feb 22 at 12:16
CASE WHEN geomintersects('layer2',"Geb_Nutz") THEN 1 WHEN geomintersects('layer3',"Geb_Nutz") THEN 2 END
– L.Eiden
Feb 22 at 12:17
If you want to change the field "Geb_Nutz" then you need to provide any field name from layer2 and layer3 for the expression. Do not use "Geb_Nutz" because that is the field you want to change. So select layer1, go to the field calculator, select to update your chosen field and use the expression:CASE WHEN geomintersects('layer2', 'layer2_field') THEN 1 WHEN geomintersects('layer3', 'layer3_field') THEN 2 END
– Joseph
Feb 22 at 12:22
add a comment |
The intersects
function requires two geometries (not layers) as input requirements as described in the help section of the field calculator:
intersects(geometry a, geometry b)
Tests whether a geometry intersects another. Returns true if the geometries spatially intersect (share any portion of space) and false if they do not.
If you want to use layer names, install the refFunctions plugin which adds more functions to the field calculator such as:
geomintersects(targetLayer,targetField)
Retrieve target field value when source feature intersects target feature in target layer.
Assuming you are using the field calculator on layer1
, you could use something like the following:
CASE
WHEN geomintersects('layer2', 'any_layer2_FieldName') THEN 1
WHEN geomintersects('layer3', 'any_layer3_FieldName') THEN 2
END
The intersects
function requires two geometries (not layers) as input requirements as described in the help section of the field calculator:
intersects(geometry a, geometry b)
Tests whether a geometry intersects another. Returns true if the geometries spatially intersect (share any portion of space) and false if they do not.
If you want to use layer names, install the refFunctions plugin which adds more functions to the field calculator such as:
geomintersects(targetLayer,targetField)
Retrieve target field value when source feature intersects target feature in target layer.
Assuming you are using the field calculator on layer1
, you could use something like the following:
CASE
WHEN geomintersects('layer2', 'any_layer2_FieldName') THEN 1
WHEN geomintersects('layer3', 'any_layer3_FieldName') THEN 2
END
answered Feb 21 at 16:11
JosephJoseph
58k7100202
58k7100202
I want to change always the same field (from the same layer). My layer1 contains different polygons, wich represent the location of buildings. With the intersect operation I want to change always the field "Geb_Nutz" (layer1), wich shows the kind of use for the building. For all the buildings, that intersect layer1 and layer2, I want to set "Geb_Nutz" to 1. For all the buildings, that intersect layer1 and layer3, I want to set "Geb_Nutz" to 2. I tried the following operation, but it still doesn't work.
– L.Eiden
Feb 22 at 12:16
CASE WHEN geomintersects('layer2',"Geb_Nutz") THEN 1 WHEN geomintersects('layer3',"Geb_Nutz") THEN 2 END
– L.Eiden
Feb 22 at 12:17
If you want to change the field "Geb_Nutz" then you need to provide any field name from layer2 and layer3 for the expression. Do not use "Geb_Nutz" because that is the field you want to change. So select layer1, go to the field calculator, select to update your chosen field and use the expression:CASE WHEN geomintersects('layer2', 'layer2_field') THEN 1 WHEN geomintersects('layer3', 'layer3_field') THEN 2 END
– Joseph
Feb 22 at 12:22
add a comment |
I want to change always the same field (from the same layer). My layer1 contains different polygons, wich represent the location of buildings. With the intersect operation I want to change always the field "Geb_Nutz" (layer1), wich shows the kind of use for the building. For all the buildings, that intersect layer1 and layer2, I want to set "Geb_Nutz" to 1. For all the buildings, that intersect layer1 and layer3, I want to set "Geb_Nutz" to 2. I tried the following operation, but it still doesn't work.
– L.Eiden
Feb 22 at 12:16
CASE WHEN geomintersects('layer2',"Geb_Nutz") THEN 1 WHEN geomintersects('layer3',"Geb_Nutz") THEN 2 END
– L.Eiden
Feb 22 at 12:17
If you want to change the field "Geb_Nutz" then you need to provide any field name from layer2 and layer3 for the expression. Do not use "Geb_Nutz" because that is the field you want to change. So select layer1, go to the field calculator, select to update your chosen field and use the expression:CASE WHEN geomintersects('layer2', 'layer2_field') THEN 1 WHEN geomintersects('layer3', 'layer3_field') THEN 2 END
– Joseph
Feb 22 at 12:22
I want to change always the same field (from the same layer). My layer1 contains different polygons, wich represent the location of buildings. With the intersect operation I want to change always the field "Geb_Nutz" (layer1), wich shows the kind of use for the building. For all the buildings, that intersect layer1 and layer2, I want to set "Geb_Nutz" to 1. For all the buildings, that intersect layer1 and layer3, I want to set "Geb_Nutz" to 2. I tried the following operation, but it still doesn't work.
– L.Eiden
Feb 22 at 12:16
I want to change always the same field (from the same layer). My layer1 contains different polygons, wich represent the location of buildings. With the intersect operation I want to change always the field "Geb_Nutz" (layer1), wich shows the kind of use for the building. For all the buildings, that intersect layer1 and layer2, I want to set "Geb_Nutz" to 1. For all the buildings, that intersect layer1 and layer3, I want to set "Geb_Nutz" to 2. I tried the following operation, but it still doesn't work.
– L.Eiden
Feb 22 at 12:16
CASE WHEN geomintersects('layer2',"Geb_Nutz") THEN 1 WHEN geomintersects('layer3',"Geb_Nutz") THEN 2 END
– L.Eiden
Feb 22 at 12:17
CASE WHEN geomintersects('layer2',"Geb_Nutz") THEN 1 WHEN geomintersects('layer3',"Geb_Nutz") THEN 2 END
– L.Eiden
Feb 22 at 12:17
If you want to change the field "Geb_Nutz" then you need to provide any field name from layer2 and layer3 for the expression. Do not use "Geb_Nutz" because that is the field you want to change. So select layer1, go to the field calculator, select to update your chosen field and use the expression:
CASE WHEN geomintersects('layer2', 'layer2_field') THEN 1 WHEN geomintersects('layer3', 'layer3_field') THEN 2 END
– Joseph
Feb 22 at 12:22
If you want to change the field "Geb_Nutz" then you need to provide any field name from layer2 and layer3 for the expression. Do not use "Geb_Nutz" because that is the field you want to change. So select layer1, go to the field calculator, select to update your chosen field and use the expression:
CASE WHEN geomintersects('layer2', 'layer2_field') THEN 1 WHEN geomintersects('layer3', 'layer3_field') THEN 2 END
– Joseph
Feb 22 at 12:22
add a comment |
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%2f313091%2fuse-intersection-in-field-calculator%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