Compute coordinates of vector line?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












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



















  • 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
















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



















  • 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














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













  • 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








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











3 Answers
3






active

oldest

votes


















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


















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














    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
      Feb 10 at 19:26











    • I want actually the numerical value, but thanks for underlining up this difference

      – kFly
      Feb 10 at 20:08










    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














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















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













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

















    • 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













    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 Feb 10 at 18:28









        J. MonticoloJ. Monticolo

        930113




        930113





















            3














            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
              Feb 10 at 19:26











            • I want actually the numerical value, but thanks for underlining up this difference

              – kFly
              Feb 10 at 20:08















            3














            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
              Feb 10 at 19:26











            • I want actually the numerical value, but thanks for underlining up this difference

              – kFly
              Feb 10 at 20:08













            3












            3








            3







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

















            • 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

















            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

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?