Compute coordinates of vector line?
Clash Royale CLAN TAG#URR8PPP
I have a set of vector lines (which represent translation vectors for georeferencing).
Based on the layer CRS, how can I compute the coordinates of each line in an attribute table ?
i.e (Xmax-Xmin; Ymax-Ymin) for each line.
I have managed to get the line length with $length in the expression editor but I am struggling with other geometrical parameters.
Edit: I am looking to "store the formula" within the layer. The idea is to keep these values automatically updated with the geometry. (Auto)update should happen if a new line is added or modification of the current geometry is done.
qgis
add a comment |
I have a set of vector lines (which represent translation vectors for georeferencing).
Based on the layer CRS, how can I compute the coordinates of each line in an attribute table ?
i.e (Xmax-Xmin; Ymax-Ymin) for each line.
I have managed to get the line length with $length in the expression editor but I am struggling with other geometrical parameters.
Edit: I am looking to "store the formula" within the layer. The idea is to keep these values automatically updated with the geometry. (Auto)update should happen if a new line is added or modification of the current geometry is done.
qgis
2
About your recent edition, look at virtual fields (stores the formula but not within the layer). About the$length()
function, it calculates the ellipsoidal length, uselength( $geometry)
instead if you want the planimetric one (probably not so). About the(Xmax-Xmin; Ymax-Ymin)
example, it is assumed to be a string of characters because a pair of values can not be attributed to a single numeric field.
– Gabriel De Luca
Feb 11 at 1:45
add a comment |
I have a set of vector lines (which represent translation vectors for georeferencing).
Based on the layer CRS, how can I compute the coordinates of each line in an attribute table ?
i.e (Xmax-Xmin; Ymax-Ymin) for each line.
I have managed to get the line length with $length in the expression editor but I am struggling with other geometrical parameters.
Edit: I am looking to "store the formula" within the layer. The idea is to keep these values automatically updated with the geometry. (Auto)update should happen if a new line is added or modification of the current geometry is done.
qgis
I have a set of vector lines (which represent translation vectors for georeferencing).
Based on the layer CRS, how can I compute the coordinates of each line in an attribute table ?
i.e (Xmax-Xmin; Ymax-Ymin) for each line.
I have managed to get the line length with $length in the expression editor but I am struggling with other geometrical parameters.
Edit: I am looking to "store the formula" within the layer. The idea is to keep these values automatically updated with the geometry. (Auto)update should happen if a new line is added or modification of the current geometry is done.
qgis
qgis
edited Feb 11 at 0:41
kFly
asked Feb 10 at 17:55
kFlykFly
3131314
3131314
2
About your recent edition, look at virtual fields (stores the formula but not within the layer). About the$length()
function, it calculates the ellipsoidal length, uselength( $geometry)
instead if you want the planimetric one (probably not so). About the(Xmax-Xmin; Ymax-Ymin)
example, it is assumed to be a string of characters because a pair of values can not be attributed to a single numeric field.
– Gabriel De Luca
Feb 11 at 1:45
add a comment |
2
About your recent edition, look at virtual fields (stores the formula but not within the layer). About the$length()
function, it calculates the ellipsoidal length, uselength( $geometry)
instead if you want the planimetric one (probably not so). About the(Xmax-Xmin; Ymax-Ymin)
example, it is assumed to be a string of characters because a pair of values can not be attributed to a single numeric field.
– Gabriel De Luca
Feb 11 at 1:45
2
2
About your recent edition, look at virtual fields (stores the formula but not within the layer). About the
$length()
function, it calculates the ellipsoidal length, use length( $geometry)
instead if you want the planimetric one (probably not so). About the (Xmax-Xmin; Ymax-Ymin)
example, it is assumed to be a string of characters because a pair of values can not be attributed to a single numeric field.– Gabriel De Luca
Feb 11 at 1:45
About your recent edition, look at virtual fields (stores the formula but not within the layer). About the
$length()
function, it calculates the ellipsoidal length, use length( $geometry)
instead if you want the planimetric one (probably not so). About the (Xmax-Xmin; Ymax-Ymin)
example, it is assumed to be a string of characters because a pair of values can not be attributed to a single numeric field.– Gabriel De Luca
Feb 11 at 1:45
add a comment |
3 Answers
3
active
oldest
votes
You can use the Field Calculator. Open the attribute table of your line layer and select the Open Filed Calculator icon from the toolbar. I use an OSM road layer.
In the Field Calculator window create a new column of decimal type, in the Geometry group of functions you can find x_min, x_max, y_min, y_max functions. To create a column with x_range of features use the next screenshot:
You can create a column for y_range in a similar way.
Thanks: that is the method I was after but I was missing $geometry to call the proper entity.
– kFly
Feb 10 at 20:18
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
Feb 11 at 0:23
or update automatically when the geometry is modified ?
– kFly
Feb 11 at 0:35
1
See this post gis.stackexchange.com/questions/178355/… or user virtual fields (virtual fields are calculated when you open the attribute table) which is technically simpler but slower.
– Zoltan
Feb 11 at 14:15
add a comment |
For QGIS 3.x, the formula in the field calculator is :
'(' || x_max($geometry) || '-' || x_min($geometry) || '; ' || y_max($geometry) || '-' || y_min($geometry) || ')'
add a comment |
Following J.Monticolo's answer, yet another expression is:
'(' || bounds_width($geometry) || '; ' || bounds_height($geometry) ||')'
kFly didn't say if (s)he want (Xmax-Xmin) as text or the result of subtraction (q.e.d. width or height). In case of text result, my solution is the good one, in the case of substraction, it's the Kazuhito's one.
– J. Monticolo
Feb 10 at 19:26
I want actually the numerical value, but thanks for underlining up this difference
– kFly
Feb 10 at 20:08
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%2f311674%2fcompute-coordinates-of-vector-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use the Field Calculator. Open the attribute table of your line layer and select the Open Filed Calculator icon from the toolbar. I use an OSM road layer.
In the Field Calculator window create a new column of decimal type, in the Geometry group of functions you can find x_min, x_max, y_min, y_max functions. To create a column with x_range of features use the next screenshot:
You can create a column for y_range in a similar way.
Thanks: that is the method I was after but I was missing $geometry to call the proper entity.
– kFly
Feb 10 at 20:18
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
Feb 11 at 0:23
or update automatically when the geometry is modified ?
– kFly
Feb 11 at 0:35
1
See this post gis.stackexchange.com/questions/178355/… or user virtual fields (virtual fields are calculated when you open the attribute table) which is technically simpler but slower.
– Zoltan
Feb 11 at 14:15
add a comment |
You can use the Field Calculator. Open the attribute table of your line layer and select the Open Filed Calculator icon from the toolbar. I use an OSM road layer.
In the Field Calculator window create a new column of decimal type, in the Geometry group of functions you can find x_min, x_max, y_min, y_max functions. To create a column with x_range of features use the next screenshot:
You can create a column for y_range in a similar way.
Thanks: that is the method I was after but I was missing $geometry to call the proper entity.
– kFly
Feb 10 at 20:18
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
Feb 11 at 0:23
or update automatically when the geometry is modified ?
– kFly
Feb 11 at 0:35
1
See this post gis.stackexchange.com/questions/178355/… or user virtual fields (virtual fields are calculated when you open the attribute table) which is technically simpler but slower.
– Zoltan
Feb 11 at 14:15
add a comment |
You can use the Field Calculator. Open the attribute table of your line layer and select the Open Filed Calculator icon from the toolbar. I use an OSM road layer.
In the Field Calculator window create a new column of decimal type, in the Geometry group of functions you can find x_min, x_max, y_min, y_max functions. To create a column with x_range of features use the next screenshot:
You can create a column for y_range in a similar way.
You can use the Field Calculator. Open the attribute table of your line layer and select the Open Filed Calculator icon from the toolbar. I use an OSM road layer.
In the Field Calculator window create a new column of decimal type, in the Geometry group of functions you can find x_min, x_max, y_min, y_max functions. To create a column with x_range of features use the next screenshot:
You can create a column for y_range in a similar way.
answered Feb 10 at 18:43
ZoltanZoltan
3,309917
3,309917
Thanks: that is the method I was after but I was missing $geometry to call the proper entity.
– kFly
Feb 10 at 20:18
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
Feb 11 at 0:23
or update automatically when the geometry is modified ?
– kFly
Feb 11 at 0:35
1
See this post gis.stackexchange.com/questions/178355/… or user virtual fields (virtual fields are calculated when you open the attribute table) which is technically simpler but slower.
– Zoltan
Feb 11 at 14:15
add a comment |
Thanks: that is the method I was after but I was missing $geometry to call the proper entity.
– kFly
Feb 10 at 20:18
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
Feb 11 at 0:23
or update automatically when the geometry is modified ?
– kFly
Feb 11 at 0:35
1
See this post gis.stackexchange.com/questions/178355/… or user virtual fields (virtual fields are calculated when you open the attribute table) which is technically simpler but slower.
– Zoltan
Feb 11 at 14:15
Thanks: that is the method I was after but I was missing $geometry to call the proper entity.
– kFly
Feb 10 at 20:18
Thanks: that is the method I was after but I was missing $geometry to call the proper entity.
– kFly
Feb 10 at 20:18
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
Feb 11 at 0:23
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
Feb 11 at 0:23
or update automatically when the geometry is modified ?
– kFly
Feb 11 at 0:35
or update automatically when the geometry is modified ?
– kFly
Feb 11 at 0:35
1
1
See this post gis.stackexchange.com/questions/178355/… or user virtual fields (virtual fields are calculated when you open the attribute table) which is technically simpler but slower.
– Zoltan
Feb 11 at 14:15
See this post gis.stackexchange.com/questions/178355/… or user virtual fields (virtual fields are calculated when you open the attribute table) which is technically simpler but slower.
– Zoltan
Feb 11 at 14:15
add a comment |
For QGIS 3.x, the formula in the field calculator is :
'(' || x_max($geometry) || '-' || x_min($geometry) || '; ' || y_max($geometry) || '-' || y_min($geometry) || ')'
add a comment |
For QGIS 3.x, the formula in the field calculator is :
'(' || x_max($geometry) || '-' || x_min($geometry) || '; ' || y_max($geometry) || '-' || y_min($geometry) || ')'
add a comment |
For QGIS 3.x, the formula in the field calculator is :
'(' || x_max($geometry) || '-' || x_min($geometry) || '; ' || y_max($geometry) || '-' || y_min($geometry) || ')'
For QGIS 3.x, the formula in the field calculator is :
'(' || x_max($geometry) || '-' || x_min($geometry) || '; ' || y_max($geometry) || '-' || y_min($geometry) || ')'
answered Feb 10 at 18:28
J. MonticoloJ. Monticolo
930113
930113
add a comment |
add a comment |
Following J.Monticolo's answer, yet another expression is:
'(' || bounds_width($geometry) || '; ' || bounds_height($geometry) ||')'
kFly didn't say if (s)he want (Xmax-Xmin) as text or the result of subtraction (q.e.d. width or height). In case of text result, my solution is the good one, in the case of substraction, it's the Kazuhito's one.
– J. Monticolo
Feb 10 at 19:26
I want actually the numerical value, but thanks for underlining up this difference
– kFly
Feb 10 at 20:08
add a comment |
Following J.Monticolo's answer, yet another expression is:
'(' || bounds_width($geometry) || '; ' || bounds_height($geometry) ||')'
kFly didn't say if (s)he want (Xmax-Xmin) as text or the result of subtraction (q.e.d. width or height). In case of text result, my solution is the good one, in the case of substraction, it's the Kazuhito's one.
– J. Monticolo
Feb 10 at 19:26
I want actually the numerical value, but thanks for underlining up this difference
– kFly
Feb 10 at 20:08
add a comment |
Following J.Monticolo's answer, yet another expression is:
'(' || bounds_width($geometry) || '; ' || bounds_height($geometry) ||')'
Following J.Monticolo's answer, yet another expression is:
'(' || bounds_width($geometry) || '; ' || bounds_height($geometry) ||')'
answered Feb 10 at 18:47
KazuhitoKazuhito
16k41882
16k41882
kFly didn't say if (s)he want (Xmax-Xmin) as text or the result of subtraction (q.e.d. width or height). In case of text result, my solution is the good one, in the case of substraction, it's the Kazuhito's one.
– J. Monticolo
Feb 10 at 19:26
I want actually the numerical value, but thanks for underlining up this difference
– kFly
Feb 10 at 20:08
add a comment |
kFly didn't say if (s)he want (Xmax-Xmin) as text or the result of subtraction (q.e.d. width or height). In case of text result, my solution is the good one, in the case of substraction, it's the Kazuhito's one.
– J. Monticolo
Feb 10 at 19:26
I want actually the numerical value, but thanks for underlining up this difference
– kFly
Feb 10 at 20:08
kFly didn't say if (s)he want (Xmax-Xmin) as text or the result of subtraction (q.e.d. width or height). In case of text result, my solution is the good one, in the case of substraction, it's the Kazuhito's one.
– J. Monticolo
Feb 10 at 19:26
kFly didn't say if (s)he want (Xmax-Xmin) as text or the result of subtraction (q.e.d. width or height). In case of text result, my solution is the good one, in the case of substraction, it's the Kazuhito's one.
– J. Monticolo
Feb 10 at 19:26
I want actually the numerical value, but thanks for underlining up this difference
– kFly
Feb 10 at 20:08
I want actually the numerical value, but thanks for underlining up this difference
– kFly
Feb 10 at 20:08
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%2f311674%2fcompute-coordinates-of-vector-line%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
2
About your recent edition, look at virtual fields (stores the formula but not within the layer). About the
$length()
function, it calculates the ellipsoidal length, uselength( $geometry)
instead if you want the planimetric one (probably not so). About the(Xmax-Xmin; Ymax-Ymin)
example, it is assumed to be a string of characters because a pair of values can not be attributed to a single numeric field.– Gabriel De Luca
Feb 11 at 1:45