Skip to main content
Question

change vertex z value through python caller

  • February 10, 2014
  • 3 replies
  • 86 views

venu
Contributor
Forum|alt.badge.img+5
Hi,

 

 

I have a polygon in that i need to change z value for 3 and 4 vertex.

 

 

Please can any one help me how to do in python

 

 

Thanks in advance
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

david_r
Celebrity
  • February 10, 2014
Hi,

 

 

have a look at the Python API documentation, it is installed with FME under <FME>/fmeobjects/python/apidoc/index.html

 

 

You can do something like:

 

 

coords = feature.getAllCoordinates()

 

if feature.hasGeometry() and len(coords) >= 4 and feature.getGeometry().is3D():

 

    coords[2] = (coords[2][0], coords[2][1], new_z_value1)

 

    coords[3] = (coords[3][0], coords[3][1], new_z_value2)

 

    feature.resetCoords()

 

    feature.addCoordinates(coords)

 

 

Be careful if you have multipart and/or aggregate geometries, though.

 

 

David

venu
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • February 12, 2014
Please can Explain how to compare the vertex z value.I don't know python codes, but i can understand if you explain.

takashi
Celebrity
  • February 12, 2014
Hi Venu,

 

 

Assume that dimension of input polygon was 3D and you have retrieved coordinates list with this expression as David suggested.

 

-----

 

coords = feature.getAllCoordinates()

 

-----

 

"coords[i]" (i is 0-based index of vertices) represents a tuple which contains (x, y, z) of vertex(i).

 

Therefore "coords[i][2]" represents z value of vertex(i), you can compare it to other value in the script.

 

Just be aware that element index of Python list and tuple is 0-based. e.g. index of the 3rd element of list or tuple is 2 (not 3).

 

 

Takashi