PyQGIS3: How to add elevation to a point?How extract the polyline length in PyQgis 3.0?Toggle Editing Add...

Creating a loop after a break using Markov Chain in Tikz

Can a planet have a different gravitational pull depending on its location in orbit around its sun?

Re-submission of rejected manuscript without informing co-authors

Where to refill my bottle in India?

How to manage monthly salary

Doomsday-clock for my fantasy planet

Lied on resume at previous job

Landing in very high winds

Need help identifying/translating a plaque in Tangier, Morocco

Does bootstrapped regression allow for inference?

Patience, young "Padovan"

Domain expired, GoDaddy holds it and is asking more money

Is ipsum/ipsa/ipse a third person pronoun, or can it serve other functions?

New order #4: World

Find the number of surjections from A to B.

Are objects structures and/or vice versa?

How to make payment on the internet without leaving a money trail?

How would photo IDs work for shapeshifters?

Why doesn't a const reference extend the life of a temporary object passed via a function?

Are cabin dividers used to "hide" the flex of the airplane?

Unbreakable Formation vs. Cry of the Carnarium

Is window.confirm() accessible?

Is there any use for defining additional entity types in a SOQL FROM clause?

How to answer pointed "are you quitting" questioning when I don't want them to suspect



PyQGIS3: How to add elevation to a point?


How extract the polyline length in PyQgis 3.0?Toggle Editing Add FeatureQGIS 3.x closestSegmentWithContext returns sqrt distance 0.0 and point doesn't snap to polylineAdd items to print layoutPython Scripting in QGIS to add features and select them?How to add a rownumber in QGIS 3 using PythonQGIS Processing Script to Create and Add CSV LayerHow to add an existing QGSVectorLayer to QGIS project?QGIS 3.4, how to add .qml style to sink in processingHow to retrieve the data source of the active layer?






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







0















I am trying to add elevation to a 2D point in a QGIS 3 plugin, preferably in a concise and straightforward way. Not finding this easy. I think part of the problem is that in QGIS 3, fromPoint() has been renamed to fromPointXY(). I am not very clear on how to create 3D point geometry.



I have tried a number of variations without finding one which works and have not been able to find a suitable example online.



Basically what I want to achieve is PointXY + elevation -> Point, which I would expect to be something like this:



z = 1.0 # or whatever

for l in selectedLayers: # for each selected layer
if l.geometryType() == QgsWkbTypes.PointGeometry: # point layer

l.startEditing()
feat = l.getFeatures()

for f in feat: # each feature

# Get existing geometry...
geom = f.geometry()
pt = geom.asPoint() # returns PointXY

# Replace with 3D geometry...
pt3D = QgsPoint(pt.x(), pt.y(), z)
geom = QgsGeometry.fromPointXY(pt3D) # error, because pt is 3D
ft.setGeometry(geom)

l.updateFeature(f)

l.commitChanges()


How do I do this?










share|improve this question































    0















    I am trying to add elevation to a 2D point in a QGIS 3 plugin, preferably in a concise and straightforward way. Not finding this easy. I think part of the problem is that in QGIS 3, fromPoint() has been renamed to fromPointXY(). I am not very clear on how to create 3D point geometry.



    I have tried a number of variations without finding one which works and have not been able to find a suitable example online.



    Basically what I want to achieve is PointXY + elevation -> Point, which I would expect to be something like this:



    z = 1.0 # or whatever

    for l in selectedLayers: # for each selected layer
    if l.geometryType() == QgsWkbTypes.PointGeometry: # point layer

    l.startEditing()
    feat = l.getFeatures()

    for f in feat: # each feature

    # Get existing geometry...
    geom = f.geometry()
    pt = geom.asPoint() # returns PointXY

    # Replace with 3D geometry...
    pt3D = QgsPoint(pt.x(), pt.y(), z)
    geom = QgsGeometry.fromPointXY(pt3D) # error, because pt is 3D
    ft.setGeometry(geom)

    l.updateFeature(f)

    l.commitChanges()


    How do I do this?










    share|improve this question



























      0












      0








      0








      I am trying to add elevation to a 2D point in a QGIS 3 plugin, preferably in a concise and straightforward way. Not finding this easy. I think part of the problem is that in QGIS 3, fromPoint() has been renamed to fromPointXY(). I am not very clear on how to create 3D point geometry.



      I have tried a number of variations without finding one which works and have not been able to find a suitable example online.



      Basically what I want to achieve is PointXY + elevation -> Point, which I would expect to be something like this:



      z = 1.0 # or whatever

      for l in selectedLayers: # for each selected layer
      if l.geometryType() == QgsWkbTypes.PointGeometry: # point layer

      l.startEditing()
      feat = l.getFeatures()

      for f in feat: # each feature

      # Get existing geometry...
      geom = f.geometry()
      pt = geom.asPoint() # returns PointXY

      # Replace with 3D geometry...
      pt3D = QgsPoint(pt.x(), pt.y(), z)
      geom = QgsGeometry.fromPointXY(pt3D) # error, because pt is 3D
      ft.setGeometry(geom)

      l.updateFeature(f)

      l.commitChanges()


      How do I do this?










      share|improve this question
















      I am trying to add elevation to a 2D point in a QGIS 3 plugin, preferably in a concise and straightforward way. Not finding this easy. I think part of the problem is that in QGIS 3, fromPoint() has been renamed to fromPointXY(). I am not very clear on how to create 3D point geometry.



      I have tried a number of variations without finding one which works and have not been able to find a suitable example online.



      Basically what I want to achieve is PointXY + elevation -> Point, which I would expect to be something like this:



      z = 1.0 # or whatever

      for l in selectedLayers: # for each selected layer
      if l.geometryType() == QgsWkbTypes.PointGeometry: # point layer

      l.startEditing()
      feat = l.getFeatures()

      for f in feat: # each feature

      # Get existing geometry...
      geom = f.geometry()
      pt = geom.asPoint() # returns PointXY

      # Replace with 3D geometry...
      pt3D = QgsPoint(pt.x(), pt.y(), z)
      geom = QgsGeometry.fromPointXY(pt3D) # error, because pt is 3D
      ft.setGeometry(geom)

      l.updateFeature(f)

      l.commitChanges()


      How do I do this?







      pyqgis-3






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 4 mins ago







      wotnot

















      asked 12 mins ago









      wotnotwotnot

      848




      848






















          0






          active

          oldest

          votes












          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%2f318193%2fpyqgis3-how-to-add-elevation-to-a-point%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f318193%2fpyqgis3-how-to-add-elevation-to-a-point%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

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

          Meter-Bus Содержание Параметры шины | Стандартизация |...