Example: Two Drawings from the Same Table

Drawings show geometry that is stored in a geometry field in a table.  We can have more than one drawing that shows the same geometry field, for example, if we would like to create more than one drawing using a different Style to show that same geometry.  Each additional drawing created from the same geometry field takes no additional space, because the common geometry used by all such drawings is just stored once in the same table.  


Tables in some databases can have only one geometry field in a table.  GPKG, for example, allows only one geometry field in a table.  PostgreSQL with the PostGIS extension can host more than one geometry field in a table, as can Manifold.   This example uses a table in a Manifold project to show how a table can have multiple geometry fields in the table, with each record having more than one geometry value.


For the simple case of creating two drawings from the same table, both of which drawings use the same geom field, please see the Example: Multiple Drawings from the Same Table topic.


For another example like this one, where a table has two geometry fields and different drawings are created using those two different geom fields, see the Example: Add a Second Computed Geom Field to a Table  topic.  See also the example, in the Creating Geometry with Computed Fields section of the Example: Add a Computed Field to a Table  topic.


This example has three objectives:



In this example we take a table with a geometry field that is visualized by a drawing.  Geometry fields are of type geom by default in Manifold, so this documentation often refers to a geometry field as simply a geom.   It is Manifold convention to name the main geometry field Geom with a capital G.  That name, which could be any legal name for a field, is the same as the name of the data type used to help us keep track of which field does what.  We could use a different name, such as George or Ringo, but using the name Geom for the geometry field makes it instantly obvious which field in a table is the geometry field.


In this example, we add a second geom field, which we will call Tgeom, to the table and create an rtree index on that field so it can be visualized by a drawing.   We copy the first drawing, paste it and adjust the pasted copy so it uses the second geom field.   We demonstrate how to use the Transform pane to show "live" modifications in the second drawing compared to the first drawing.

Tables and the Transform Pane

The Transform pane operates on whatever open component has the focus when the Transform pane is launched.  For example, if we open a table window and then choose the Transform pane, the pane will operate on that table.  The Transform templates available will be those which make sense for that table and for the specific field within the table chosen as the target field.  Whatever previews in blue preview color the pane does will be done within that table, showing the result that would happen to the target field.


Such previews will not be passed on and displayed in other components.  For example, a preview in a table for a transform template will not also create a preview in a drawing window that visualizes data from a geom field in the table.   That is because the preview is just a preview, not a change in the actual table data.  Other components, like drawings, which display the actual data in the table will continue to display the actual data.   If we want other components to change we must change the actual data which they display.


We could always open the drawing and click on a template in the Transform pane to see a preview in the drawing; however, sometimes we are working within the drawing's table and not in the drawing.    We would like to see what a transform will do to a drawing even though we are working in the table.  We might want to  experiment with data in a table but at the same time we might also want to see what changes such experimentation causes in other components, such as drawings, which depend upon data in the table.   That is easy to do.


If we want to experiment with changes to a geom field without actually changing the geom field, we simply create an additional geom field that can function as a copy of the geom field or as a temporary scratch pad to hold changed versions of the geom field.  We can then create a drawing that uses the additional geom field.  We can then make changes to the copied geom field to see what happens.


In this example we use a name of Tgeom (a mnemonic for "Temporary Geom")  for that temporary scratch pad field.   We can then create a second drawing, which in this example we name Tgeom Drawing, shows whatever is in Tgeom.    We can then use Tgeom as the target field for Transform templates, using Geom as the source field and we can press Update Field to actually change the data within Tgeom so that any components, like Tgeom Drawing, which utilize that field can update as well.


Geom never gets modified: it is just the source field from which data is copied or which is used to feed the Transform template that puts data into our temporary scratch pad field, Tgeom.   That allows us to try out as many templates as we like to see what effect they have on Tgeom in the preview in the table, and then, by pressing Update Field to update Tgeom to see what effect they have on the Tgeom Drawing.


At any time when we are done experimenting we can fill Tgeom full of NULL values again or simply delete that field as well as the temporary, Tgeom Drawing that showed its contents and the table will be back to the way it was originally, with Geom completely unmodified.

Drawings and the Transform Pane

When a drawing is open and has the focus, choosing the Transform pane, the pane will operate on that drawing.   Fields that are available in the pane will be fields in the table from which the drawing takes its geom data for visualization.    In many cases, the Transform templates that are available to work on those fields will be the same as those that are available when the drawing's table is the context for the Transform pane.  


When a Transform pane is opened in the context of a drawing any previews the Transform pane causes will be shown in the drawing.   We can exploit that effect to see what a particular template does to objects in the drawing using the preview without any need to press the Update Field button.


Important: The Transform pane can show previews for its work in a drawing if there is at least one object in the drawing.   Drawings cannot host previews if they are empty, that is, where there are no records in the associated table or where the values for all records in the geom field the drawing uses are NULL values.  That is true even if the preview would involve filling the NULL values with non-NULL geom values.

Examples Using the Transform Pane and a Table

Our project has an Objects table and an Objects Drawing.




We open the Objects Drawing.




We zoom to fit, and then zoom out one click on our wheel mouse so that all objects are visible.  The objects appear using default, gray Style for drawings, since we have not styled the drawing to use different colors or symbology.




We can take a look at the Component pane to see what projection the drawing uses.  We see it is the default Pseudo-Mercator projection, and we remember that for use later when we create another geometry field in the table.


We open the table. 




The table has the usual mfd_id identity field that is used for an index, and a geometry field called Geom containing values of data type geom.  There are three areas, two lines and two points in the table.


To add another field we choose Edit - Schema to open the schema for the table.




btn_schema_add.pngPress the Add command button and choose Field in the drop down menu.




In the Field dialog, enter Tgeom as the name of the new field and geom as the type.  Press OK.




The new Tgeom field appears in provisional, bluish color in the Schema dialog, the provisional color indicating the field has not yet been added to the table's schema.   We press Save Changes to commit the changes, creating the new field in the table, and exiting the Schema dialog.




A new geometry field called Tgeom appears in the table.  So far it is filled with NULL values.    

Create a Second Drawing using the Same Table

We will now create a second drawing to use the new Tgeom field.




In the Project pane we right-click on the Objects table and then in the context menu we choose Create - New Drawing.




In the New Drawing dialog we Name the new drawing Tgeom Drawing.   The dialog is already loaded with the Objects table and the geometry fields in the table.  In the Geometry box we choose Tgeom.




When we created the Tgeom field in the Schema dialog, we could have also created a spatial index on that field.  However, it is easier to leave the default Create spatial index box checked, so the New Drawing dialog will automatically create that spatial index for us.   


By default, a new drawing is created assuming the geometry field is in the default Pseudo-Mercator projection.  We will use that, since the existing Geom field also uses Pseudo-Mercator, as we saw in the Components pane illustration near the beginning of this topic.


We press Create Drawing.



The new drawing appears in the Project.  To open it we can double-click on the Tgeom Drawing.




When we open the Tgeom Drawing it shows nothing, because the drawing has been created from a geometry field, Tgeom, within the Objects table that is full of NULL values.

Populate the Tgeom Field

We will now populate the Tgeom field using the Transform pane to put values into the Tgeom field based on existing values in the Geom field.   


With the focus on the opened Objects table, we choose the Transform pane.




In the Transform pane we choose Tgeom in the upper box as the target field, we click on the Copy template to choose that template and then we choose Geom in the lower box as the source, value field.




The Transform pane immediately previews in blue preview color, what the Copy template will do using current settings.


When we press Update Field in the Transform pane,  the values for each record in the Geom field will be copied into the Tgeom field.




To see the objects in the Tgeom Drawing we Ctrl-click on the drawing's layer tab, which is a command to Zoom to Fit the contents of that layer.  We could also press the Zoom to Fit button on the main toolbar.  




We then use the mouse wheel to click out one zoom level to provide a bit of empty margin, to ensure any points on the periphery of the drawing are better in view.  The view is identical to what we see in the Objects Drawing because the objects now in the Tgeom field that the Tgeom Drawing window shows were copied from the Geom field that the Objects Drawing window shows.



Changing Objects in the Tgeom Field

Using Tgeom as the target field and Geom as the source field we can choose different templates in the Transform pane and as we click Update Field the results of the transform will be put into the Tgeom field and the Tgeom Drawing automatically will show them.




For example, we can choose the Buffer template with a Distance of 5.  We create buffers of 5 meters based on the geometry of objects in the Tgeom field, putting the results into the Tgeom field.




The Tgeom column in the table will be drawn in blue preview color to show that field will be affected.   When we press the Update Field button the Tgeom field will get updated.




We can see the results in an immediate comparison if we leave both the Objects Drawing and the Tgeom Drawing open next to each other at the same time.




Increasing the Distance to 15 while still using Buffer and then pressing Update Field shows us what effect increasing the Distance has on the objects created by the Buffer template.  


In the illustration above, we would like to make a fresh start, and instead of creating buffers based on what is in the Tgeom field (already populated with buffer areas at a buffer distance of 5 meters), we create buffers based on the original geometry in the Geom field.  The settings in the Transform pane shown above create buffers of 15 meters based on the geometry of objects in the Geom field, and put the results into the Tgeom field.




The greater Distance means the borders of the buffer areas are created further away from the edges of the objects from which they are created.




Choosing Convert to Point and pressing Update Field shows how the template creates points at the locations of coordinates which define objects in the source field.




Since we are using the Transform pane with Geom as the source field and Tgeom as the target field the Geom field is not modified.   Only the Tgeom field is modified.




For our last example we will click on Enclosing Rect and press Update Field.




The result is to place into Tgeom area objects which are the enclosing boxes for line and area objects in the source geom field, that is, the minimal sized rectangular areas that full enclose the source objects.  Points are replaced with a pseudo-area that has all four coordinates at the same location, and which is indicated by small square symbols.

Examples Using the Transform Pane and a Drawing

Let us re-start the above example from the point where we had a blank Tgeom Drawing.   If we have been experimenting with this example and the Tgeom field is not empty, that is, full of NULL values, we can fill it with NULL values by using the Copy template with a Value of Null and pressing Update Field.




With the drawing open and the focus on the drawing we choose the Transform pane to operate on that drawing.


Drawings which are empty cannot show previews so our first order of business is to copy the Geom field contents into the Tgeom field so the Tgeom Drawing has something to show:




We press the Update Field button since we want to actually change the data in Tgeom to values other than NULL.




Much better.   The drawing can now preview what we do in the Transform pane.




When we click on the Bounds template in the Transform pane (partial view above), right away the system previews the result in the drawing.




The Bounds template (see the Transform Templates - Geom topic) puts a point at the start and the end of each line and draws a line around the outer boundary of each area.   It replaces points with NULLs.  


We are looking at a preview in the above illustration: as long as we do not click the Update Field button, no change is made to the contents of the Tgeom geometry field.




Click on the Convert to Point template and the drawing window immediately previews the points it creates.




As discussed in the Notes to the Transform pane topic, the points created by Convert to Point are multipoints.


Cheating a bit with Style - The illustrations in this topic make slight adjustments to default Style for drawings.  Instead of using 1 point width for area borders, line widths and stroke width for point symbols, we use .75 point widths.  That provides a thinner, cleaner look for the small illustrations used.

See Also



Transform Pane


Transform Options


Transform Templates


Transform Templates - Drawings


Transform Templates - Boolean


Transform Templates - Datetime


Transform Templates - Geom


Transform Templates - Numeric


Transform Templates - Text


Example: Drawings use Geom Fields in Tables  - An essential discussion on how drawings are created from geom fields in tables, including how the drawing knows which coordinate system to use.


Example: Multiple Drawings from the Same Table - Illustrates how easy it is to create multiple drawings that use the same table and same geometry by copying and pasting an existing drawing.  Each new drawing takes no additional storage space in the project, but can be formatted differently.   


Example: Add a Computed Field to a Table - In this example we add a computed field to a table, illustrating how the computed field automatically changes when changes are made in the fields it uses for computation.   We also show how computed fields can use geometry, automatically updating centroids when areas are changed.  Last, we show how geometry can be created using computed fields, to create effective radius circles for antennas based on the power of the antenna..


Example: Add a Second Computed Geom Field to a Table  - We can create tables with more than one geom field in the table and then we can create drawings which use those additional geom fields.   This topic shows how to create a second geom that is a computed field based on the first geom.  The topic also shows some "real world" methods, such as how to remember the use of a geometry function to do what we want, and how to restore a geom that has been moved.    We close with some illustrations of how multiple geoms might be used, and how selection from any drawing or labels based on the same record selects the corresponding objects or labels in all other components based on that record.


Example: Create a Drawing from a Geocoded Table - A geocoded table has records with a latitude and longitude for each record.   This example starts with a table containing a list of cities with a latitude and longitude field for the location of each city.   We create a geom from the latitude and longitude fields using a template in the Transform pane and then we create a drawing that shows the cities as points.  This example shows all the infrastructure steps involved.


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: Edit a Drawing with Transform Templates - In this example we open a drawing and edit objects in the drawing using Transform pane templates.  Includes examples of using the Add Component button and also the Edit Query button.


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 using the Add Component button and also the Edit Query button.