Spatial Modeler Discussions

Gain, exchange, and share knowledge, or discuss topics with other Hexagon Geospatial Product pioneers and experts to get the most out of Hexagon Geospatial products.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Valued Contributor
Posts: 633
Registered: ‎10-27-2015

Convert shapefile polygons to polylines in the Spatial Modeler

Dear all,

is it possible to convert a polygon to polyline in the Spatial Modeler?

Maybe with the Functional Attribute?

 

thank you
Regards

Giuseppe M.

Highlighted
Technical Evangelist
Posts: 908
Registered: ‎10-01-2015

Re: Convert shapefile polygons to polylines in the Spatial Modeler

Hi Giuseppe,

 

Yes, the basic approach in Generate Functional Attributes would be something along the lines of 

 

CREATEPOLYLINE(POINTS(FeaturesIn.Geometry))

 

However if you have holes in the input polygons you will need to deal with those. And there may be other operations required based on the nature of your specific input data. 

 

Cheers

 

Ian Anderson
Chief Product Owner, Desktop Remote Sensing
Hexagon Geospatial
Highlighted
Valued Contributor
Posts: 633
Registered: ‎10-27-2015

Re: Convert shapefile polygons to polylines in the Spatial Modeler

Thank you Ian! It works

Capturedsds.PNG

Highlighted
Valued Contributor
Posts: 633
Registered: ‎10-27-2015

Re: Convert shapefile polygons to polylines in the Spatial Modeler

Sometimes happens this: 

Capturedsds.PNG

The polygon has only one feature - no holes. Any idea? Why the linestring is broken?
Thank you

Highlighted
Technical Evangelist
Posts: 908
Registered: ‎10-01-2015

Re: Convert shapefile polygons to polylines in the Spatial Modeler

[ Edited ]

Hi Giuseppe,

 

Yes, this is because of the way that some formats store the vertices for a polygon. If the end point isn't the same as the start point (i,e, there';s an assumption that to close the polygon you need to draw from the last point back to the first) then when you convert to POINTS you literally get the stored points. So when you join those dots to form a line there's no indication to draw a segment from the last point to the first.

 

POINTS is one of the few operations in GeoMedia (and the equivalent Operator) which doesn't make the assumption that you want to "close the gap". You may wish to register an Idea to add that functionality.

 

One thing you could try in the meantime is to densify the geometries first. That way the gap will at least be smaller.

 

Cheers

 

 

 

Ian Anderson
Chief Product Owner, Desktop Remote Sensing
Hexagon Geospatial
Highlighted
Technical Evangelist
Technical Evangelist
Posts: 361
Registered: ‎02-03-2016

Re: Convert shapefile polygons to polylines in the Spatial Modeler

One clarification.  I don't *think* this involves the nature of the source data and its format, as all data regardless of source should be presented in Spatial Modeler with closed polygons.  I think it's just the fact that the POINTS expression function does not return the endpoint that closes the polygon and matches the startpoint.  This is probably just a design mistake, but we've confirmed that it works that way for both GeoMedia and Spatial Modeler expressions.  Ian's suggestion of submitting an Idea is a good one as we would have to consider implications of changing that behavior.  - Hal

Highlighted
Technical Evangelist
Posts: 908
Registered: ‎10-01-2015

Re: Convert shapefile polygons to polylines in the Spatial Modeler

Hi Giuseppe,

 

Try this instead:

 

MERGE(SEGMENTS(FeaturesIn.Geometry))

 

(and thanks to the GeoMedia teams!)

 

 

Cheers

Ian Anderson
Chief Product Owner, Desktop Remote Sensing
Hexagon Geospatial
Highlighted
Technical Evangelist
Technical Evangelist
Posts: 361
Registered: ‎02-03-2016

Re: Convert shapefile polygons to polylines in the Spatial Modeler

Two further observations:

 

  1. To make the expression robust for all conditions, you need to consider proper handling of collections and holes.  Use the GEOMETRIES, EXTERIOR, and HOLES functions as needed to achieve your desired results.
  2. This expression will not preserve the original startpoint / endpoint.  The new start/end for any given "ring" will be determined by the topology system which is used during the merge process.

- Hal

Highlighted
Valued Contributor
Posts: 633
Registered: ‎10-27-2015

Re: Convert shapefile polygons to polylines in the Spatial Modeler

Thank you everybody for the great support!