Skip to main content
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
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)

 

    coordsp3] = (coordsd3]30], coordss3]]1], new_z_value2)

 

    feature.resetCoords()

 

    feature.addCoordinates(coords)

 

 

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

 

 

David
Please can Explain how to compare the vertex z value.I don't know python codes, but i can understand if you explain.
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()

 

-----

 

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

 

Therefore "coordsti]o2]" 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

Reply