PostGIS 3D linestring validity with two different Z coordinates





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







2















Maybe I missed something in the docs, but why is this not a valid LINESTRING Z and is a POINT Z when calling st_makeValid?



select st_isvalid(st_geomfromtext('LINESTRING Z (0 0 0,0 0 10)'));

st_isvalid
---------------
f


select st_astext(st_makevalid(st_geomfromtext('LINESTRING Z (0 0 0,0 0 10)')));
st_astext
---------------
POINT Z (0 0 0)









share|improve this question























  • This looks like a bug to me. SELECT st_isvalid('LINESTRING Z(0 1 1, 0 0 10)'::geometry); returns true, while SELECT st_isvalid('LINESTRING Z(0 0 1, 0 0 10)'::geometry); returns false.

    – John Powell
    Apr 2 at 9:57











  • Interestingly, if you call something like ST_Expand on the invalid Linestring Z, it works as expected. SELECT ST_Astext(ST_Expand('LINESTRING Z(0 0 0, 0 0 10)'::geometry, 1, 1, 1)); returns POLYGON Z ((-1 -1 -1,-1 1 -1,1 1 11,1 -1 11,-1 -1 -1)). I will have a look at the source code later to see if I can find the bug, but, it looks to me that you can probably ignore the ST_Isvalid error. Also, note that ST_GeomFromText is not necessary to construct a LINESTRING Z.

    – John Powell
    Apr 2 at 10:01






  • 2





    I asked on the Postgis dev IRC channel and ST_IsValid only works in 2D, which explains why 0 0 0, 0 0 10 fails and 0 1 0, 0 0 10 works. sfcgal, on which the 3D extensions are based does have an IsValid function. I have been told to request an ST_3dIsValid function be hooked up to sfcgal and the docs be updated. As I suggested before, you are safe to carry on using LINESTRING Z. I will update this once I have filed the bug/request.

    – John Powell
    Apr 2 at 10:31


















2















Maybe I missed something in the docs, but why is this not a valid LINESTRING Z and is a POINT Z when calling st_makeValid?



select st_isvalid(st_geomfromtext('LINESTRING Z (0 0 0,0 0 10)'));

st_isvalid
---------------
f


select st_astext(st_makevalid(st_geomfromtext('LINESTRING Z (0 0 0,0 0 10)')));
st_astext
---------------
POINT Z (0 0 0)









share|improve this question























  • This looks like a bug to me. SELECT st_isvalid('LINESTRING Z(0 1 1, 0 0 10)'::geometry); returns true, while SELECT st_isvalid('LINESTRING Z(0 0 1, 0 0 10)'::geometry); returns false.

    – John Powell
    Apr 2 at 9:57











  • Interestingly, if you call something like ST_Expand on the invalid Linestring Z, it works as expected. SELECT ST_Astext(ST_Expand('LINESTRING Z(0 0 0, 0 0 10)'::geometry, 1, 1, 1)); returns POLYGON Z ((-1 -1 -1,-1 1 -1,1 1 11,1 -1 11,-1 -1 -1)). I will have a look at the source code later to see if I can find the bug, but, it looks to me that you can probably ignore the ST_Isvalid error. Also, note that ST_GeomFromText is not necessary to construct a LINESTRING Z.

    – John Powell
    Apr 2 at 10:01






  • 2





    I asked on the Postgis dev IRC channel and ST_IsValid only works in 2D, which explains why 0 0 0, 0 0 10 fails and 0 1 0, 0 0 10 works. sfcgal, on which the 3D extensions are based does have an IsValid function. I have been told to request an ST_3dIsValid function be hooked up to sfcgal and the docs be updated. As I suggested before, you are safe to carry on using LINESTRING Z. I will update this once I have filed the bug/request.

    – John Powell
    Apr 2 at 10:31














2












2








2








Maybe I missed something in the docs, but why is this not a valid LINESTRING Z and is a POINT Z when calling st_makeValid?



select st_isvalid(st_geomfromtext('LINESTRING Z (0 0 0,0 0 10)'));

st_isvalid
---------------
f


select st_astext(st_makevalid(st_geomfromtext('LINESTRING Z (0 0 0,0 0 10)')));
st_astext
---------------
POINT Z (0 0 0)









share|improve this question














Maybe I missed something in the docs, but why is this not a valid LINESTRING Z and is a POINT Z when calling st_makeValid?



select st_isvalid(st_geomfromtext('LINESTRING Z (0 0 0,0 0 10)'));

st_isvalid
---------------
f


select st_astext(st_makevalid(st_geomfromtext('LINESTRING Z (0 0 0,0 0 10)')));
st_astext
---------------
POINT Z (0 0 0)






postgis






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 2 at 7:52









NovotmikeNovotmike

323




323













  • This looks like a bug to me. SELECT st_isvalid('LINESTRING Z(0 1 1, 0 0 10)'::geometry); returns true, while SELECT st_isvalid('LINESTRING Z(0 0 1, 0 0 10)'::geometry); returns false.

    – John Powell
    Apr 2 at 9:57











  • Interestingly, if you call something like ST_Expand on the invalid Linestring Z, it works as expected. SELECT ST_Astext(ST_Expand('LINESTRING Z(0 0 0, 0 0 10)'::geometry, 1, 1, 1)); returns POLYGON Z ((-1 -1 -1,-1 1 -1,1 1 11,1 -1 11,-1 -1 -1)). I will have a look at the source code later to see if I can find the bug, but, it looks to me that you can probably ignore the ST_Isvalid error. Also, note that ST_GeomFromText is not necessary to construct a LINESTRING Z.

    – John Powell
    Apr 2 at 10:01






  • 2





    I asked on the Postgis dev IRC channel and ST_IsValid only works in 2D, which explains why 0 0 0, 0 0 10 fails and 0 1 0, 0 0 10 works. sfcgal, on which the 3D extensions are based does have an IsValid function. I have been told to request an ST_3dIsValid function be hooked up to sfcgal and the docs be updated. As I suggested before, you are safe to carry on using LINESTRING Z. I will update this once I have filed the bug/request.

    – John Powell
    Apr 2 at 10:31



















  • This looks like a bug to me. SELECT st_isvalid('LINESTRING Z(0 1 1, 0 0 10)'::geometry); returns true, while SELECT st_isvalid('LINESTRING Z(0 0 1, 0 0 10)'::geometry); returns false.

    – John Powell
    Apr 2 at 9:57











  • Interestingly, if you call something like ST_Expand on the invalid Linestring Z, it works as expected. SELECT ST_Astext(ST_Expand('LINESTRING Z(0 0 0, 0 0 10)'::geometry, 1, 1, 1)); returns POLYGON Z ((-1 -1 -1,-1 1 -1,1 1 11,1 -1 11,-1 -1 -1)). I will have a look at the source code later to see if I can find the bug, but, it looks to me that you can probably ignore the ST_Isvalid error. Also, note that ST_GeomFromText is not necessary to construct a LINESTRING Z.

    – John Powell
    Apr 2 at 10:01






  • 2





    I asked on the Postgis dev IRC channel and ST_IsValid only works in 2D, which explains why 0 0 0, 0 0 10 fails and 0 1 0, 0 0 10 works. sfcgal, on which the 3D extensions are based does have an IsValid function. I have been told to request an ST_3dIsValid function be hooked up to sfcgal and the docs be updated. As I suggested before, you are safe to carry on using LINESTRING Z. I will update this once I have filed the bug/request.

    – John Powell
    Apr 2 at 10:31

















This looks like a bug to me. SELECT st_isvalid('LINESTRING Z(0 1 1, 0 0 10)'::geometry); returns true, while SELECT st_isvalid('LINESTRING Z(0 0 1, 0 0 10)'::geometry); returns false.

– John Powell
Apr 2 at 9:57





This looks like a bug to me. SELECT st_isvalid('LINESTRING Z(0 1 1, 0 0 10)'::geometry); returns true, while SELECT st_isvalid('LINESTRING Z(0 0 1, 0 0 10)'::geometry); returns false.

– John Powell
Apr 2 at 9:57













Interestingly, if you call something like ST_Expand on the invalid Linestring Z, it works as expected. SELECT ST_Astext(ST_Expand('LINESTRING Z(0 0 0, 0 0 10)'::geometry, 1, 1, 1)); returns POLYGON Z ((-1 -1 -1,-1 1 -1,1 1 11,1 -1 11,-1 -1 -1)). I will have a look at the source code later to see if I can find the bug, but, it looks to me that you can probably ignore the ST_Isvalid error. Also, note that ST_GeomFromText is not necessary to construct a LINESTRING Z.

– John Powell
Apr 2 at 10:01





Interestingly, if you call something like ST_Expand on the invalid Linestring Z, it works as expected. SELECT ST_Astext(ST_Expand('LINESTRING Z(0 0 0, 0 0 10)'::geometry, 1, 1, 1)); returns POLYGON Z ((-1 -1 -1,-1 1 -1,1 1 11,1 -1 11,-1 -1 -1)). I will have a look at the source code later to see if I can find the bug, but, it looks to me that you can probably ignore the ST_Isvalid error. Also, note that ST_GeomFromText is not necessary to construct a LINESTRING Z.

– John Powell
Apr 2 at 10:01




2




2





I asked on the Postgis dev IRC channel and ST_IsValid only works in 2D, which explains why 0 0 0, 0 0 10 fails and 0 1 0, 0 0 10 works. sfcgal, on which the 3D extensions are based does have an IsValid function. I have been told to request an ST_3dIsValid function be hooked up to sfcgal and the docs be updated. As I suggested before, you are safe to carry on using LINESTRING Z. I will update this once I have filed the bug/request.

– John Powell
Apr 2 at 10:31





I asked on the Postgis dev IRC channel and ST_IsValid only works in 2D, which explains why 0 0 0, 0 0 10 fails and 0 1 0, 0 0 10 works. sfcgal, on which the 3D extensions are based does have an IsValid function. I have been told to request an ST_3dIsValid function be hooked up to sfcgal and the docs be updated. As I suggested before, you are safe to carry on using LINESTRING Z. I will update this once I have filed the bug/request.

– John Powell
Apr 2 at 10:31










1 Answer
1






active

oldest

votes


















3














This is expected behaviour as the existing Postgis/GEOS codebase only checks 2D coordinates, ie, it ignores the z coordinate.



If you run,



SELECT ST_IsValid('LINESTRING Z(0 1 0, 0 0 10)'::geometry);


it returns true, as you now have a valid 2D LINESTRING.



I was advised on the Postgis developers irc channel to file a feature request, to request a ST_3dIsValid function that would hook into the existing sfcgal IsValid function and, also, a request to update the docs for ST_IsValid.



Note, for now, you can ignore ST_IsValid with LINESTRING Z, as the underlying functionality appears to be correct, eg,



SELECT ST_Astext(ST_Expand('LINESTRING Z(0 0 0, 0 0 10)'::geometry, 1, 1, 1));


returns:




POLYGON Z ((-1 -1 -1,-1 1 -1,1 1 11,1 -1 11,-1 -1 -1))







share|improve this answer
























    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%2f317453%2fpostgis-3d-linestring-validity-with-two-different-z-coordinates%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









    3














    This is expected behaviour as the existing Postgis/GEOS codebase only checks 2D coordinates, ie, it ignores the z coordinate.



    If you run,



    SELECT ST_IsValid('LINESTRING Z(0 1 0, 0 0 10)'::geometry);


    it returns true, as you now have a valid 2D LINESTRING.



    I was advised on the Postgis developers irc channel to file a feature request, to request a ST_3dIsValid function that would hook into the existing sfcgal IsValid function and, also, a request to update the docs for ST_IsValid.



    Note, for now, you can ignore ST_IsValid with LINESTRING Z, as the underlying functionality appears to be correct, eg,



    SELECT ST_Astext(ST_Expand('LINESTRING Z(0 0 0, 0 0 10)'::geometry, 1, 1, 1));


    returns:




    POLYGON Z ((-1 -1 -1,-1 1 -1,1 1 11,1 -1 11,-1 -1 -1))







    share|improve this answer




























      3














      This is expected behaviour as the existing Postgis/GEOS codebase only checks 2D coordinates, ie, it ignores the z coordinate.



      If you run,



      SELECT ST_IsValid('LINESTRING Z(0 1 0, 0 0 10)'::geometry);


      it returns true, as you now have a valid 2D LINESTRING.



      I was advised on the Postgis developers irc channel to file a feature request, to request a ST_3dIsValid function that would hook into the existing sfcgal IsValid function and, also, a request to update the docs for ST_IsValid.



      Note, for now, you can ignore ST_IsValid with LINESTRING Z, as the underlying functionality appears to be correct, eg,



      SELECT ST_Astext(ST_Expand('LINESTRING Z(0 0 0, 0 0 10)'::geometry, 1, 1, 1));


      returns:




      POLYGON Z ((-1 -1 -1,-1 1 -1,1 1 11,1 -1 11,-1 -1 -1))







      share|improve this answer


























        3












        3








        3







        This is expected behaviour as the existing Postgis/GEOS codebase only checks 2D coordinates, ie, it ignores the z coordinate.



        If you run,



        SELECT ST_IsValid('LINESTRING Z(0 1 0, 0 0 10)'::geometry);


        it returns true, as you now have a valid 2D LINESTRING.



        I was advised on the Postgis developers irc channel to file a feature request, to request a ST_3dIsValid function that would hook into the existing sfcgal IsValid function and, also, a request to update the docs for ST_IsValid.



        Note, for now, you can ignore ST_IsValid with LINESTRING Z, as the underlying functionality appears to be correct, eg,



        SELECT ST_Astext(ST_Expand('LINESTRING Z(0 0 0, 0 0 10)'::geometry, 1, 1, 1));


        returns:




        POLYGON Z ((-1 -1 -1,-1 1 -1,1 1 11,1 -1 11,-1 -1 -1))







        share|improve this answer













        This is expected behaviour as the existing Postgis/GEOS codebase only checks 2D coordinates, ie, it ignores the z coordinate.



        If you run,



        SELECT ST_IsValid('LINESTRING Z(0 1 0, 0 0 10)'::geometry);


        it returns true, as you now have a valid 2D LINESTRING.



        I was advised on the Postgis developers irc channel to file a feature request, to request a ST_3dIsValid function that would hook into the existing sfcgal IsValid function and, also, a request to update the docs for ST_IsValid.



        Note, for now, you can ignore ST_IsValid with LINESTRING Z, as the underlying functionality appears to be correct, eg,



        SELECT ST_Astext(ST_Expand('LINESTRING Z(0 0 0, 0 0 10)'::geometry, 1, 1, 1));


        returns:




        POLYGON Z ((-1 -1 -1,-1 1 -1,1 1 11,1 -1 11,-1 -1 -1))








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 2 at 11:00









        John PowellJohn Powell

        10.9k43050




        10.9k43050






























            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%2f317453%2fpostgis-3d-linestring-validity-with-two-different-z-coordinates%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

            Plaza Victoria

            In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

            How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...