Transform - Geometry: Clean

The Clean  template appears in the template list when a geometry field, of type geom, geommfd, or geomwkb, has been picked in the Transform pane.   It cleans and modify geometry.

 

Clean

Clean the geometry of objects using available operations:

 

  • convert curves to lines, - Replace curvilinear segments with the number of straight line segments given in the Curve limit parameter, to the given tolerance, with a tolerance of 0 indicating automatic tolerance.
  • fill missing z - Set z values in objects that do not have z values to the given value.  
  • fill z - Set z values in all objects to the given value.
  • normalize metric - Normalize object metrics by removing redundant coordinates and branches.
  • remove curves - Replace all curvilinear segments with straight line segments.
  • remove z - Remove z information from geometry.

 

Launch the template by choosing a geometry field and then double-clicking the Clean template.  When the template launches we can specify options.

 

 

Clean :

convert curves to lines

Replace all curved segments of line and area objects in the source field with linear, that is, straight, segments using the number of straight segments specified in the Curve limit parameter to replace each curved part of curved segments.  Put the result into the specified Result destination.  Copy straight line segments of line and area objects unmodified, and copy point objects unmodified.   

 

As discussed in the Editing Drawings topic, curved segments may be a poor choice in GIS and in some circumstances should be replaced with linear segments.  The convert curves to lines operation makes that easy.

 

 

Using the sample Objects Drawing we zoom into a line, seen above, that contains curved segment.

 

 

The curved segment is the arc extending approximately half-way around a circle.  Depending on the zoom level used for a view, it may appear to be made up of straight line segments.  Display windows approximate curved segments with a limited number of linear segments, especially when the view is zoomed out and the curved segment is small.   

 

We will replace all curved segments in the drawing with straight line segments, using the above view to see what happens to the curved segment it shows.

 

With the focus on the drawing, in the Transform pane we choose the Geom field and then we choose the Clean template.

 

 

In the Clean template we choose the convert curves to lines operation.  We begin with a Curve limit of 100, using a Tolerance of 0 for automatic tolerance.  

 

We choose New Table and specify Limit 100 for the name of the new drawing.   As we enter the name for the drawing, the pane will automatically fill in an analogous name for the table.   We can change that if we like.  Press Transform.

 

A new Limit 100 drawing appears in the Project pane.  We drag and drop the new Limit 100 drawing as a layer into the Objects Drawing window.    

 

We will repeat this operation using different Curve limit values, using Style to color lines in the resulting new drawings using different colors to allow easy comparison.

 

 

Using a Curve limit of 100 results in a smooth-looking line, which, depending on zoom level, may appear to be even smoother than the original curved segment as approximated in the initial rendering.   A Curve limit of 100 replaces the original curved segment with 101 straight line segments (zero based counting is used).

 

 

A Curve limit of 5 results in six segments being used.

 

 

A Curve limit of 3 results in four segments being used.

 

 

A Curve limit of 2 results in three segments being used.   

 

The Curve limit parameter applies to individual curve parts within a curved segment.  Circle arcs and Ellipse arcs have only one curved part per curved segment, but spline segments have a curve part between every two control points that define the spline.  If a spline has many control points, then each curved part of the spline between them will be linearized with as many straight segments as specified by the Curve limit parameter.

 

Clean : fill missing z

Set z values in objects that do not have z values to the given value.  

Clean: fill z

Specify a Z value for each object in the source field and save the resulting Z-valued objects into the Result destination.   Normally used by choosing Same Field for the Result destination, thus setting the specified Z value as the Z value for objects in place.   Check the Transform selection only box to restrict to the selection.   

 

For example, if we want to set the Z value of four points to 147, we select those points, choose the geometry field as the source field, choose Clean as the template, and then within the template choose fill z as the operation.  WE specify the Z value desired, we check the Transform selection only box, and then press Transform.

 

Clean : normalize metric

Normalize object metrics by removing redundant coordinates in objects in the source field, and put the result into the specified Result destination.  Replace curved segments with straight line segments.  Remove redundant branches, for example within lines so that a line consisting of multiple branches placed end to end will become a line with a single branch.

 

 

We start with the Redundant coords drawing above showing objects that are similar to those in our usual sample drawing.   One of the objects, the triangular area on the left, has been edited by hand to insert two redundant coordinates.

 

 

Zooming in we see that two extra coordinates have been inserted, so the area boundary goes from the first vertex that defines the area out to a coordinate location above and to the left and then immediately back to the coordinate location of the first vertex.  That creates a dimensionless, spurious, out-and-back jump in coordinates that is redundant to defining the area.

 

With the focus on the drawing, in the Transform pane we choose the Geom field and then we choose the Clean template.

 

 

In the Clean template we choose the normalize metric operation.  We leave the Tolerance option at the default 0 setting, for automatic tolerance.  Since the Tolerance is 0, the unit of measure we choose in the Unit box is irrelevant.

 

We choose New Field as the Result destination and specify  Cleaned Geom as the name of the new geometry field to add to the table.   We specify Cleaned coords for the name of the new drawing based on that new geometry field.   Press Transform.

 

A new Cleaned coords drawing appears in the Project pane.  We drag and drop the new Cleaned coords drawing as a layer into the Redundant coords window.   

 

 

We can see from the Cleaned coords drawing that the dimensionless redundancy has been eliminated.  

 

Zooming out to the original view, we also see a change in the line in the center because the curved segment has been replaced with straight segments as part of the normalization process.

 

See the Coordinates topic.

 

The normalize metric operation is similar to Normalize Topology.   See the Normalizing Topology topic for a discussion of differences.

 

Clean : remove curves

Replace each curved segment in lines or areas in the source field with a single straight segment and put the result into the specified Result destination.  Copy point objects unmodified.  The remove curves operation is useful in some circumstances, but the Clean : convert to lines operation is more frequently used, since it preserves the shape of curves by replacing each curved segment with many straight line segments which approximate the shape of the curve.

 

 

We zoom into our example drawing, which has only one object with a curved segment, the line object in the center.  

 

With the focus on the drawing, in the Transform pane we choose the Geom field and then we choose the Clean template.

 

 

In the Clean template we choose the remove curves operation.   We choose New Field as the Result destination and specify Nocurves Geom as the name of the new geometry field to add to the table.   We specify Objects without curves for the name of the new drawing based on that new geometry field.   Press Transform.

 

A new Objects without curves drawing appears in the Project pane.  We drag and drop the new Objects without curves drawing as a layer into the Objects Drawing window.   

 

The  Objects without curves drawing shows how the curve is replaced with a straight line segment from the first coordinate of the curve to the last coordinate of the curve.

 

Clean : remove z

Remove z information from geometry.

 

Notes

Curvilinear segments - As a practical matter, most people doing GIS will use straight line segments for lines and areas.   Few GIS systems do a good job of supporting curved segments, so there is much less data published using curved segments.   Manifold's ability to work with curved segments allows us to use that data within Manifold in a limited way, at least for display and interactive editing.  

 

However, most processing tools in Manifold, such as Transform templates and various Geom SQL functions, do their work by first converting a curvilinear segment into a straight line segment between the same two start and finish coordinates.  That will often lead to weird or otherwise unexpected results.  To avoid such problems, first convert curvilinear segments into equivalent constellations of straight line segments at whatever resolution is desired, using the Clean transform template with the convert curves to lines operation option and the number of linear segments desired to approximate the curve in the Curve limit parameter.   See the Curved Segments discussion in the Drawings topic.

 

See Also

Transform Pane

 

Transform Reference

 

Transform - Expression

 

Transform - Geometry