insert python geometry to postgis geometry type










0














What is the proper solution for inserting python geometry from shapely to PostGIS geometry type?
I have found different approaches, but all of them seems to be incorrect...



  1. PPyGIS - PostGIS adapter for Psycopg - seems that this package is out-of-date, an advice here is not to use the package


  2. The reversed question, suggests shapely.wkb.loads(hex_geom[0], hex=True), I'm not sure, is it necessary to dumps and then loads geometry ?



  3. Geoalchemy module method from_shape(Point(5, 45), srid=4326), when importing get



    psycopg2.ProgrammingError: can't adapt type 'WKBElement'




  4. ST_GeomFromText - really the only one solution?

In my code I get a Linestring and I have to insert it into PostGIS as



st_makeline(ARRAY[st_startpoint(%s), st_line_interpolate_point(%s, 0.15), st_line_interpolate_point(%s, 0.5), st_line_interpolate_point(%s, 0.85), st_endpoint(%s)])


I'm puzzled because it's a really mess to convert my Linestring geometry to string, then use ST_GeomFromText every time I call my geometry in st_makeline



Can anyone point towards how to insert Shapely geometry to PostGIS?










share|improve this question




























    0














    What is the proper solution for inserting python geometry from shapely to PostGIS geometry type?
    I have found different approaches, but all of them seems to be incorrect...



    1. PPyGIS - PostGIS adapter for Psycopg - seems that this package is out-of-date, an advice here is not to use the package


    2. The reversed question, suggests shapely.wkb.loads(hex_geom[0], hex=True), I'm not sure, is it necessary to dumps and then loads geometry ?



    3. Geoalchemy module method from_shape(Point(5, 45), srid=4326), when importing get



      psycopg2.ProgrammingError: can't adapt type 'WKBElement'




    4. ST_GeomFromText - really the only one solution?

    In my code I get a Linestring and I have to insert it into PostGIS as



    st_makeline(ARRAY[st_startpoint(%s), st_line_interpolate_point(%s, 0.15), st_line_interpolate_point(%s, 0.5), st_line_interpolate_point(%s, 0.85), st_endpoint(%s)])


    I'm puzzled because it's a really mess to convert my Linestring geometry to string, then use ST_GeomFromText every time I call my geometry in st_makeline



    Can anyone point towards how to insert Shapely geometry to PostGIS?










    share|improve this question


























      0












      0








      0







      What is the proper solution for inserting python geometry from shapely to PostGIS geometry type?
      I have found different approaches, but all of them seems to be incorrect...



      1. PPyGIS - PostGIS adapter for Psycopg - seems that this package is out-of-date, an advice here is not to use the package


      2. The reversed question, suggests shapely.wkb.loads(hex_geom[0], hex=True), I'm not sure, is it necessary to dumps and then loads geometry ?



      3. Geoalchemy module method from_shape(Point(5, 45), srid=4326), when importing get



        psycopg2.ProgrammingError: can't adapt type 'WKBElement'




      4. ST_GeomFromText - really the only one solution?

      In my code I get a Linestring and I have to insert it into PostGIS as



      st_makeline(ARRAY[st_startpoint(%s), st_line_interpolate_point(%s, 0.15), st_line_interpolate_point(%s, 0.5), st_line_interpolate_point(%s, 0.85), st_endpoint(%s)])


      I'm puzzled because it's a really mess to convert my Linestring geometry to string, then use ST_GeomFromText every time I call my geometry in st_makeline



      Can anyone point towards how to insert Shapely geometry to PostGIS?










      share|improve this question















      What is the proper solution for inserting python geometry from shapely to PostGIS geometry type?
      I have found different approaches, but all of them seems to be incorrect...



      1. PPyGIS - PostGIS adapter for Psycopg - seems that this package is out-of-date, an advice here is not to use the package


      2. The reversed question, suggests shapely.wkb.loads(hex_geom[0], hex=True), I'm not sure, is it necessary to dumps and then loads geometry ?



      3. Geoalchemy module method from_shape(Point(5, 45), srid=4326), when importing get



        psycopg2.ProgrammingError: can't adapt type 'WKBElement'




      4. ST_GeomFromText - really the only one solution?

      In my code I get a Linestring and I have to insert it into PostGIS as



      st_makeline(ARRAY[st_startpoint(%s), st_line_interpolate_point(%s, 0.15), st_line_interpolate_point(%s, 0.5), st_line_interpolate_point(%s, 0.85), st_endpoint(%s)])


      I'm puzzled because it's a really mess to convert my Linestring geometry to string, then use ST_GeomFromText every time I call my geometry in st_makeline



      Can anyone point towards how to insert Shapely geometry to PostGIS?







      python-3.x postgis shapely shapely.geometry






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 13:28

























      asked Nov 12 at 7:49









      Jane

      1277




      1277



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fstackoverflow.com%2fquestions%2f53257806%2finsert-python-geometry-to-postgis-geometry-type%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


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





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2fstackoverflow.com%2fquestions%2f53257806%2finsert-python-geometry-to-postgis-geometry-type%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







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3