Compute coordinates of vector line?












1















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.










share|improve this question




















  • 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


















1















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.










share|improve this question




















  • 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
















1












1








1








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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, 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
















  • 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










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












3 Answers
3






active

oldest

votes


















3














For QGIS 3.x, the formula in the field calculator is :



'(' || x_max($geometry) || '-' || x_min($geometry) || '; ' || y_max($geometry) || '-' || y_min($geometry) || ')'





share|improve this answer































    3














    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.



    enter image description here



    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:



    enter image description here



    You can create a column for y_range in a similar way.






    share|improve this answer
























    • 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



















    2














    Following J.Monticolo's answer, yet another expression is:



    '(' || bounds_width($geometry) || '; ' || bounds_height($geometry) ||')'





    share|improve this answer
























    • 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











    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    3














    For QGIS 3.x, the formula in the field calculator is :



    '(' || x_max($geometry) || '-' || x_min($geometry) || '; ' || y_max($geometry) || '-' || y_min($geometry) || ')'





    share|improve this answer




























      3














      For QGIS 3.x, the formula in the field calculator is :



      '(' || x_max($geometry) || '-' || x_min($geometry) || '; ' || y_max($geometry) || '-' || y_min($geometry) || ')'





      share|improve this answer


























        3












        3








        3







        For QGIS 3.x, the formula in the field calculator is :



        '(' || x_max($geometry) || '-' || x_min($geometry) || '; ' || y_max($geometry) || '-' || y_min($geometry) || ')'





        share|improve this answer













        For QGIS 3.x, the formula in the field calculator is :



        '(' || x_max($geometry) || '-' || x_min($geometry) || '; ' || y_max($geometry) || '-' || y_min($geometry) || ')'






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 9 hours ago









        J. MonticoloJ. Monticolo

        664112




        664112

























            3














            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.



            enter image description here



            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:



            enter image description here



            You can create a column for y_range in a similar way.






            share|improve this answer
























            • 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
















            3














            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.



            enter image description here



            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:



            enter image description here



            You can create a column for y_range in a similar way.






            share|improve this answer
























            • 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














            3












            3








            3







            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.



            enter image description here



            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:



            enter image description here



            You can create a column for y_range in a similar way.






            share|improve this answer













            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.



            enter image description here



            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:



            enter image description here



            You can create a column for y_range in a similar way.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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



















            • 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











            2














            Following J.Monticolo's answer, yet another expression is:



            '(' || bounds_width($geometry) || '; ' || bounds_height($geometry) ||')'





            share|improve this answer
























            • 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
















            2














            Following J.Monticolo's answer, yet another expression is:



            '(' || bounds_width($geometry) || '; ' || bounds_height($geometry) ||')'





            share|improve this answer
























            • 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














            2












            2








            2







            Following J.Monticolo's answer, yet another expression is:



            '(' || bounds_width($geometry) || '; ' || bounds_height($geometry) ||')'





            share|improve this answer













            Following J.Monticolo's answer, yet another expression is:



            '(' || bounds_width($geometry) || '; ' || bounds_height($geometry) ||')'






            share|improve this answer












            share|improve this answer



            share|improve this answer










            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



















            • 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


















            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]