Compute coordinates of vector line?
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
1
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
2 hours ago
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 3 hours ago
kFly
asked 9 hours ago
kFlykFly
3061314
3061314
1
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
2 hours ago
add a comment |
1
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
2 hours ago
1
1
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
2 hours ago
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
2 hours ago
add a comment |
3 Answers
3
active
oldest
votes
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 |
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
7 hours ago
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
3 hours ago
or update automatically when the geometry is modified ?
– kFly
3 hours ago
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
8 hours ago
I want actually the numerical value, but thanks for underlining up this difference
– kFly
7 hours ago
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
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 9 hours ago
J. MonticoloJ. Monticolo
664112
664112
add a comment |
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
7 hours ago
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
3 hours ago
or update automatically when the geometry is modified ?
– kFly
3 hours ago
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
7 hours ago
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
3 hours ago
or update automatically when the geometry is modified ?
– kFly
3 hours ago
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 9 hours ago
ZoltanZoltan
3,284917
3,284917
Thanks: that is the method I was after but I was missing $geometry to call the proper entity.
– kFly
7 hours ago
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
3 hours ago
or update automatically when the geometry is modified ?
– kFly
3 hours ago
add a comment |
Thanks: that is the method I was after but I was missing $geometry to call the proper entity.
– kFly
7 hours ago
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
3 hours ago
or update automatically when the geometry is modified ?
– kFly
3 hours ago
Thanks: that is the method I was after but I was missing $geometry to call the proper entity.
– kFly
7 hours ago
Thanks: that is the method I was after but I was missing $geometry to call the proper entity.
– kFly
7 hours ago
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
3 hours ago
Is there a method to automatically compute these parameters for each line created within this layer as soon as they are created ?
– kFly
3 hours ago
or update automatically when the geometry is modified ?
– kFly
3 hours ago
or update automatically when the geometry is modified ?
– kFly
3 hours ago
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
8 hours ago
I want actually the numerical value, but thanks for underlining up this difference
– kFly
7 hours ago
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
8 hours ago
I want actually the numerical value, but thanks for underlining up this difference
– kFly
7 hours ago
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 8 hours ago
KazuhitoKazuhito
15.4k31678
15.4k31678
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
8 hours ago
I want actually the numerical value, but thanks for underlining up this difference
– kFly
7 hours ago
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
8 hours ago
I want actually the numerical value, but thanks for underlining up this difference
– kFly
7 hours ago
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
8 hours ago
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
8 hours ago
I want actually the numerical value, but thanks for underlining up this difference
– kFly
7 hours ago
I want actually the numerical value, but thanks for underlining up this difference
– kFly
7 hours ago
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
1
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
2 hours ago