Skip to main content
Solved

Turning a mesh into a polygon


redgeographics
VIP
Forum|alt.badge.img+63

Seemingly simple question: I have a KMZ file with mesh objects in its placemark folder, I need to get these written to a shapefile. Any ideas? I tried a GeometryCoercer, no luck.

Best answer by takashi

Hi @redgeographics, the data contains a feature which has a MultiSurface geometry consisting of two Mesh geometries. A possible way is:

  1. Deaggregator: MultiSurface -> individual Meshes
  2. GeometryCoercer (Geometry Type: fme_composite_surface): Meshes -> CompositeSurfaces
  3. GeometryPartExtractor: Extract polygon parts from the CompositeSurfaces, with this setting.

View original
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.

5 replies

geosander
Forum|alt.badge.img+7

You could try a Triangulator. The Triangles port will give you individual triangle polygons. With a Dissolver (or if that gets too messy and you don't mind multipolygons, an Aggregator) you could glue the whole thing together.


takashi
Celebrity
  • Best Answer
  • March 23, 2017

Hi @redgeographics, the data contains a feature which has a MultiSurface geometry consisting of two Mesh geometries. A possible way is:

  1. Deaggregator: MultiSurface -> individual Meshes
  2. GeometryCoercer (Geometry Type: fme_composite_surface): Meshes -> CompositeSurfaces
  3. GeometryPartExtractor: Extract polygon parts from the CompositeSurfaces, with this setting.


itay
Supporter
Forum|alt.badge.img+19
  • Supporter
  • March 23, 2017

A some what less elegant but working alternative is:

  1. Deaggregator
  2. GeometryFilter (everything but NULL)
  3. Triangulator >Triangles
  4. Second Deaggregator
  5. GeometryCoercer >fme_polygon

     

and voila, you have polygons.


redgeographics
VIP
Forum|alt.badge.img+63

Thanks @takashi, that did the trick. The data does come out in a local coordinate system but the prj file checks out and my mapping software seems to be able to put it in its right place.


takashi
Celebrity

Good to hear. Alternatively, a Deaggregator and a PythonCaller with this script could work more efficiently.

import fmeobjects
class MeshToPolygons(object):
    def input(self, feature):
        mesh = feature.getGeometry()
        if isinstance(mesh, fmeobjects.FMEMesh):
            vertices = mesh.getVertices()
            for part in mesh:
                indices = part.getVertexIndices()
                if indices:
                    boundary = fmeobjects.FMELine([vertices[i] for i in indices])
                    feature.setGeometry(fmeobjects.FMEPolygon(boundary))
                    self.pyoutput(feature)