Clip (Transform)

This topic covers the Clip transform template.  For the Clip interactive editing command used to edit the geometry of objects, including existing objects or to create new areas or lines that are automatically trimmed to the inside or outside of areas, see the Clip topic.

 

The Clip template in the Transform pane cuts all objects in the target drawing using areas in an accessory drawing, called the Clip with drawing.   The Keep inner part check box regulates what is left after the clip.   Checking the Keep inner part check box leaves only those portions of objects in the target drawing that are inside of the Clip with areas.   Unchecking the Keep inner part check box leaves only those portions of objects that are outside of the Clip with areas.

 

 The Clip transform template is a different command than the interactive Clip editing command.  The names are the same because the logic applied is the same, but the actions of the two commands are different.  

Example: Clip an Area with Other Areas

Consider a map that has two drawing layers:  a drawing that shows Texas as an area, and a drawing called Objects that has a circular area and a star-shaped area.   The map uses 60% opacity for layers in the Layers pane to better show overlaps.

 

 

In the Transform pane we choose the Texas layer, and we choose the Geom field.  We then double-click the Clip template to launch it.

 

 

In the Clip template, we choose the Objects layer in the Clip with box and we uncheck the Keep inner part  box.   If we wanted to use only selected objects within the Objects layer to clip the Texas layer, we could select those objects and check the Clip with selection only box.   We leave that box unchecked.

 

For the Result, we choose New Table and then enter Clipped as the name of the new drawing and an analogous name for the drawing's table.   

 

Press Preview to see a preview.  We do not have to do a preview if we do not want, but it is often wise to see a preview before applying a transform, just in case we have made any mistakes setting up the transform.

 

 

The preview appears in blue preview color, with a blue preview caption bar at the top of the window reporting the name of the template being previewed.  Previews are drawn on top of all other layers.  We can toggle the preview off and on by clicking the blue preview caption bar at the top of the window, or we can close the preview entirely by right-clicking the caption bar and choosing Hide Preview.

 

The preview shows that all of Texas within the Clip with layer's areas will be clipped, and since we have unchecked the Keep inner part box, only those parts of Texas that are not within the clipping star and circle will be left.

 

Previews can be slow with very many complex objects.  Even if we do not wait for the preview to appear, the Clip will still be done correctly.  The actual Clip operation might be slow with very many objects or very complex objects, even though it is fully parallel.

 

Press Transform.

 

A new Clipped drawing and table appear in the Project pane.

 

 

We drag and drop the new Clipped drawing into the map, styling it in blue color as seen above.   The state of Texas started off as one area, so what is created by the Clip is still only one area object, a multi-branched area

Keeping the inner part

To clip Texas with the circle and star and leave the inner part, we re-run the transform but this time we check the Keep inner part box.

 

 

We specify a different name for the new drawing and table, Clipped keep inner.

 

Press Preview.

 

 

The preview shows that all of Texas inside the Clip with layer's areas will be retained, with all of Texas outside of the circle and star removed.

 

Press Transform.  

 

A new Clipped keep inner drawing and table appear in the Project pane.

 

 

We drag and drop the new Clipped keep inner drawing into the map, styling it in purple color as seen above.   The state of Texas started off as one area, so what is created by the Clip is still only one area object, a multi-branched area

 

 

We can show both results layers, and also turn on the Objects layer to see how the different areas created by the Clip and the Clip using the Keep inner part  box relate to each other, and to the objects that were used as the Clip with objects.

Example: Clip Lines with an Area

Consider a map that has two drawing layers:  a drawing that shows the French region of Centre as an area, and a drawing called Roads that shows Roman roads in Europe as lines.   We will clip the Roads lines using the Centre area.

 

 

We will clip the roads layer with the region of Centre.  

 

In the Transform pane we choose the Roads layer, and we choose the Geom field.  We then double-click the Clip template to launch it.

 

 

In the Clip template, we choose the Centre layer in the Clip with box and we uncheck the Keep inner part  box.  If we wanted to use only selected objects within the Objects layer to clip the Texas layer, we could select those objects and check the Clip with selection only box.   We leave that box unchecked.

 

For the Result, we choose New Table and then enter Clipped Roads as the name of the new drawing and an analogous name for the drawing's table.   

 

Press Preview to see a preview.

 

 

The preview shows that all Roman roads inside the Clip with layer's area will be clipped.  If we would like a clearer view of the preview, to see what will be left when the Roads layer is transformed,  we can double-click the Roads layer tab to turn off that layer.   The preview still continues to show even if the subject layer is turned off.

 

Press Transform.

 

A new Clipped Roads drawing and table appear in the Project pane.

 

 

We drag and drop the new Clipped Roads drawing into the map, coloring the clipped roads dark green.  We have altered the Style of the Centre layer in a new layer called Centre outline, to better show how the roads were cut out by the Centre area.

Keeping the inner part

 

To clip the roads layer with Centre and leave the inner part, we re-run the transform but this time we check the Keep inner part box.

 

 

We specify a different name for the new drawing and table, Clipped Roads keep inner.

 

Press Preview.

 

 

The preview shows that all roads within the Clip with layer's area will be retained, with all roads outside of Centre removed.  If we would like a clearer view of the preview, to see what will be left when the Roads layer is transformed,  we can double-click the Roads layer tab to turn off that layer.   The preview still continues to show even if the subject layer is turned off.

 

Press Transform.  

 

A new Clipped Roads keep inner drawing and table appear in the Project pane.

 

 

We drag and drop the new Clipped Roads keep inner drawing into the map, as seen above, with the roads colored in purple.   We have changed the Style of the Centre region, showing it in a style that has a faint inner border in green, to better emphasize the interior of the area,  to better show how the roads were cut by the Centre area.

 

 

We can show both results layers, above left, and also show the results layers with the Center outline layer, above right.   This illustrates how the different sets of clipped roads created by checking or unchecking the Keep inner part box relate to each other.

 

 In the example above, roads which seem to be deleted by the Clip simply have their geometries set to NULL values.  The records are still there in the table, just not existing in the drawing because they have NULL geometry.   To get rid of such zombie records, use the procedure in the Eliminating NULL Records section at the end of this topic.

Clip Points with Areas

The Clip transform template uses areas to clip all types of objects in the drawing being clipped:  areas, lines and points.   While the power of Clip is obvious when clipping areas and lines, the convenience of Clip is also very useful as a way of creating subsets of points, as an alternative to selecting on an attribute field.  

 

Consider, for example, the map below, where we have a drawing layer showing US states as areas and a drawing layer showing cities with populations greater than 50,000 as points.   We would like to get points for only California.

 

 

We click the US states tab to move the focus onto that tab, and then we Ctrl-click California to select that state's polygonal area.

 

With the focus on the map, in the Transform pane we choose the US cities layer, choosing the Geom field in that layer.    We double-click the Clip template to launch it.

 

 

In the Clip template, the Clip with choice will automatically be the US states layer, since that is the only other layer in the map.   If we had more drawing layers in the map, we could choose which layer we wanted to use as the Clip with layer.  

 

We check the Clip with selection only box.  To see how the Keep inner part box works, we uncheck the box and press Preview.  

 

 

Unchecking the Keep inner part box tells Manifold to not keep what is inside the clipping area.   The preview shows that the result of the transform will be all cities except those within the selected area, California.

 

We want to keep only those cities within California, so we will check the Keep inner part box.

 

 

We check the Keep inner part box and then press Preview again.

 

 

That shows what the results of the Clip will be, keeping the inner part, that is, keeping cities inside the selected area, California.

Two Options

To launch the transform, we have two options for how to save the results of the transform.  

 

The first option is put the results back into the same field, altering the US cities table to put NULL values into the geometry fields of all city records except those in California.   That works for display purposes, because cities with NULL geometry will not appear in the drawing.

 

The second option is to write the results to a new drawing that we create.   That has the advantage of not altering the US cities drawing and table with which we started.   If we discover we made a mistake in workflow, we can start with the original, unmodified US cities drawing again.  

First option: Update field "in place"

We will update the table "in place."

 

 

The default setting for the Result option is (same field), which alters the geometry "in place."   For points, there is no partial clipping of geometry the way there might be for an area or line object: the point is either there or, if clipped, it has NULL geometry and is not there.   Press Transform.

 

 

The result is that all of the points outside of California disappear.

 

 

If we pop open the US cities drawing's table, we see that the reason those points disappeared is that the Clip operation clipped, that is, deleted, their geometry.  The records for those cities are still in the table, but their geometry has been clipped to a NULL value, so they do not appear in the drawing.

Second option: Save result to a new drawing and table

The second option writes the result of the transform template into a new drawing and table.  That has the advantage of preserving the original data unmodified.

 

Suppose we did not do the first option, so we are still working with a full set of US cities.   

 

 

In the Clip template we would choose New table for the Result option.    We would specify CA cities as the name for the New drawing and an analogous name for the drawing's table.  We can specify any name we like, but it makes sense to use a name that describes what is in the new drawing.

 

Press Transform.

 

Instantly, a new drawing and its table called CA cities appears in the Project pane.

 

 

We drag and drop the CA cities layer into the map, turning off the US cities layer and styling the CA cities layer with inverted yellow triangles as point icons.  In the illustration above we have also deselected the California area in the US states layer.

 

 

If we pop open the drawing's table, sorting by STATE we see that the only records in the new CA cities drawing which have non-NULL geometry are cities in California.

Eliminating NULL Records

Suppose we want only non-NULL records in our table, so that the results table only contains records within California?   That is easy to do.

 

With the focus on the opened CA cities Table window,  in the Select pane we choose the Geom field.   We can also have the focus on the open Map window and in the Select pane choose the CA cities layer and then the Geom field.

 

Double-click the Null template to launch it.

 

 

In the Null template, choose null as the condition and press Select.

 

 

That selects all records where the Geom field is NULL.     

 

Press Edit - Delete to delete the selected records.

 

 

The result is a table with records that have non-NULL geometry, all the cities being in California.

Notes

Works with all objects at once - In the examples above, we have shown the Clip template in action clipping areas in example, lines in a different example, and points in a third example.   Three examples were used for clarity, but if a drawing had a mix of areas, lines and points, the Clip template would clip all three types of objects at once.

 

Automatically removes NULL geometry records - The Clip transform automatically removes records with NULL geometry when producing a new table.

 

Why not just select for CA in the STATE field? - In the example clipping points with areas we used Clip to get records with geometry only in California.   Would it have been easier to use the Select pane to select for all records where the STATE field contained CA?   In this particular case yes, because our US cities table includes a STATE attribute that gives the two letter postal abbreviation for the state in which each city is located.   However, suppose our US cities table did not have a STATE field?   In that case, the only way we would know what state each city was in would be by using a spatial operation such as Clip.   Another option instead of using Clip would have been to use the JOIN dialog, doing a spatial join to add a STATE field to each record in the US cities table, the STATE field being taken from a join using the US states layer.  We could then select on the STATE field.

 

Old Centre - The illustrations in this topic show Centre as it was before 1 January 2016, when a law passed in 2014 took effect that reduced the number of regions in France from 22 to 13.  

 

See Also

Clip

 

Transform Pane

 

Transform Reference

 

Transform - Geometry: Clip

 

Example: Clip Areas with a Transform Expression - Use the Expression tab of the Transform pane to clip areas in a drawing to fit within horizontal bounds.   Includes examples of using the Add Component button and also the Edit Query button.