In this example we open a drawing and apply Transform pane templates, using preview in blue preview color to see what the templates do.
User interfaces for the Transform pane have been changed. See the Transform Reference topic for guides to new interfaces while this topic is updated.
We begin by opening a map with one layer, a drawing of Mexico that shows provinces as areas.
We launch the Transform pane.
In the Transform pane we chose the only geom field in the drawing, a field called Geom. If we click on any template the action of that template will be immediately previewed in the drawing window.
For example, if we click on Convert to Line that template will immediately be previewed in the drawing as if it were applied to the Geom field's geometry.
We can see that the Convert to Line template converts area objects into line objects that correspond to the area boundaries. If we do not click the Update Field button this is just a preview and makes no change to the data.
Clicking another template will instantly preview the action of that template as well.
For example, clicking Convert to Point shows a preview of converting the area objects to point objects at the coordinates which define the areas. The Keep branches option would convert branched lines to multibranched point objects, if desired.
Clicking Enclosing Rect ...
... shows a preview of replacing the areas with rectangular areas that precisely enclose each area.
In the illustration above enclosing rectangles are drawn in whatever happens to be the display order of area objects. Normally in the case of overlapping objects we would control the order of display by using layers in a map. If display order matters, it is not a good idea to create area objects which overlap each other within the same drawing. Instead, we should use layers to control display order.
To see the areas as they were without any preview we click the (no action) template row at the top of the list of templates in the Transform pane.
We will now explore how the operation of the Transform pane can be restricted to the selection. We begin by Ctrl-clicking onto some areas in the drawing to select them. See the Selection topic for selecting objects in a drawing with the mouse.
First, by Ctrl-clicking it we can select the area shown above, the Mexican province of Durango.
The selected area is displayed in red selection color.
Next, we check the Restrict to selection box, click Rotate and then enter 45 into the Angle box which appears when we click the Rotate template.
Right away the drawing window shows a preview of what the Rotate template does. The selected area has been rotated 45 degrees. Because of overlap and the order in which areas are drawn the rotated area is partially above some areas and partially below others.
We can see that effect a bit more clearly by clicking Enclosing Rect.
In the preview we can see how the Enclosing Rect template has been applied to just the selected object. If we like, we can select more areas in the drawing by Ctrl-clicking on them.
As we Ctrl-click each object to add it to the selection, the Enclosing Rect template preview automatically will apply to that object as well.
The Enclosing Rect template now applies to all three selected areas. Next, we uncheck the Restrict to selection box.
Instantly, the preview in the drawing window updates to apply the Enclosing Rect template to all of the areas.
If we click on a different template...
...that too will be applied to all the objects and not just to the selected ones.
At any time we can check or uncheck the Restrict to selection box.
If we check it again...
...once more only the selected areas will have the Rotate template preview applied to them. If we Shift-Ctrl-click one of the selected areas to de-select it...
...it will no longer be part of the selection and the Rotate preview will not apply to it.
So far all we have done has resulted in a preview in the drawing window of changes the Transform template would make. To commit those changes we must press the Update Field button.
Or, if we prefer instead of making changes to the original data we can write the changes to a new component. This will create a new component that contains only the modified objects, that is, just the rotated areas, which are created by the template.
To do so we change the Update Field action in the pull-down menu to Add Component.
We can then click on Add Component.
Two new components, a new table and a drawing for that table, will be created in the Project pane.
We can drag and drop the Mexico Table Rotate Drawing into the map to see that this new drawing shows the two selected provinces in Mexico as rotated by the template. These two rotated provinces are copies of the original data, as rotated. The original Mexico drawing has not been changed.
The illustration above we have double-clicked off the original Mexico drawing layer, more clearly to see the new layer that has been added.
If desired, we can take a look at the SQL query that the template uses to work its magic. For a simpler query, we switch the command button to Update Field.
To do so, press the Edit Query button and the SQL used by the template will be loaded into the Command Window as an automatically generated SQL query.
The query text in the Command Window is:
-- Transform - Rotate - Update Field
PRAGMA ('progress.percentnext' = '100');
GeomRotate([Geom], GeomCenter([Geom], 0), 45) AS [n_Geom]
FROM CALL Selection([Mexico], TRUE)
) SET [Geom] = [n_Geom];
The above query shows how the Rotate template works, and it also shows the call to the Selection query function that implements a restriction to only selected objects. The PRAGMA controls the progress bar, not likely to be seen given how fast queries work unless we have a very large drawing. The THREADS statement implements parallelization to the maximum number of CPU cores available.
We can modify this query or save it for later use. Pressing the Edit Query button does not change the original drawing. It simply opens up a Command Window with an SQL query that would be used by the template if we pressed the Update Field button.
Inherited fields - Objects that are created as a result of Transform operations will whenever possible inherit the data content of the fields for that record. If we replace a state in Mexico with the Enclosing Rect for that state, the alteration when we choose Upgrade Field is to the contents of the geom field. Other fields for that record, for example, any field that gives the population of the state, remain unchanged.
Example: Two Drawings from the Same Table - Take a table with a geom field that is visualized by a drawing. Add a second geom field to the table and create an rtree index on that field so it can be visualized by a drawing. Copy the first drawing, paste it and adjust the pasted copy so it uses the second geom field. Demonstrate how to use the Transform pane to show "live" modifications in the second drawing compared to the first drawing.
Example: Copy one Column into Another Column with Transform - How to use the Transform pane to copy the contents of one column in a table into another column, but only for selected records. Uses the Products table from the Nwind example data set.
Example: Transform Field Values using an Expression in the Transform Pane - How the Expressions tab of the Transform pane may be used to change the values of fields.
Example: Construct JSON String using Select and Transform - Use the Select pane and the Transform pane to manually construct a JSON string using values from other fields in a table. Shows how we can manipulate text to build desired contents in a field.
Example: Use a Transform Expression to Create Buffers in a Drawing - Use the Expression tab of the Transform pane to create three different sizes of buffers for different lines in a drawing and then automatically create a query which does the same thing. Includes examples of saving results to a new component and also the Edit Query button.
Example: Transform Templates, Expressions and Queries - We learn to use a function by clicking on a template in the Transform pane , seeing what it does in a preview, looking at the query Manifold creates and then trying out the function in the Expression tab.