In this example we take a tour of the relationship between drawings and tables. We look at how a drawing takes geometry data from a table and how it knows which coordinate system to use. The very first part repeats some information from the Drawings topic to give us a running start.
Consider a drawing, called Provinces, that shows provinces (regions) in France as areas.
If we right-click on the Provinces drawing in the Project pane and choose Properties we can see the properties for the drawing.
The properties tell us that the Provinces drawing takes its data from a table called Provinces Table and that within that table it uses a geom field called Geom.
Opening the Provinces table we can see that it does indeed include a field called Geom of type geom. That field contains geom values that encode area objects.
If we right-click on the Provinces Table table in the Project pane and choose Properties we can see the properties for the table.
The FieldCoordSystem.Geom property contains a value starting with a curly left bracket { which is a JSON specification for the coordinate system to be used with the contents of the Geom field. Most of the JSON string is out of sight, but if we read the entire string we would see that this particular drawing using Orthographic projection centered on France.
We can diagram the above relationships as follows:
The drawing's properties tell it which table to use and which field within that table contains the geom information for the drawing. The table's properties specify which coordinate system to use for each geom type field that is in the table.
Tech Tip: There is nothing magic about using the name Geom for the field which contains geom types. The field could just as easily be called Harry or Geometric Data for Objects or any other legal field name. Naming the field Geom is just a habit for most Manifold users and it is the default name used by Manifold when it creates such fields. Using that name by default is convenient since everybody automatically knows what it is when they see it. It certainly is less confusing than naming the field Harry.
To show how that works, we open Provinces Table and then choose Edit - Schema. We add a field of type geom that we call Jeff. We then add a spatial index called Jeff_x based on Jeff using the procedure given in the Example: Add a Spatial Index to a Table topic.
Next, using the Transform pane we copy the contents of the Geom field into the Jeff field using the procedure given in the Example: Copy one Column into Another Column with Transform topic.
We now have a Provinces Table with two geom fields, one named Geom and the other named Jeff. We now will add a property to the table's properties that will advertise what coordinate system should be used for the geom values in the Jeff field.
We right-click onto the Provinces Table in the Project pane and choose Properties. In the properties dialog we right-click onto the FieldCoordSystem.Geom cell and choose Copy. We then double-click into that cell next to the * new row marker, and press Ctrl-V to paste, so that most of the new property name is pasted for us. We then manually change the Geom at the end to Jeff and press Enter, which adds a property called FieldCoordSystem.Jeff.
We right-click into the value cell for FieldCoordSystem.Geom and Copy the contents, which specify the coordinate system to use. We then right-click into the value cell for FieldCoordSystem.Jeff and Paste the coordinate system. Press OK to update the table's properties.
The result is that we have added a new property to the table which gives the coordinate system to be used for the geom field named Jeff
Now all we have to do is create a drawing that will use Jeff instead of Geom. Doing that is easy.
We right-click on Provinces Table in the Project pane and choose Create - New Drawing In the New Drawing dialog we use Provinces 2 as the Name and we choose Jeff as the field to use for Geometry. Press Create Drawing
We right-click the Provinces 2 drawing in the Project pane and choose Properties. In the properties dialog we see the FieldGeom property value is Jeff. Press OK. The drawing Provinces 2 takes its geometry information from the Jeff field in the Provinces Table.
If we open the Provinces 2 drawing and Zoom to Fit we see it is exactly the same as the Provinces drawing. That makes sense, since we created the Jeff geometry values by copying the Geom geometry values that the Provinces drawing uses.
In the above we show how two different drawings can be created using two different geom fields in the same table, similar to the Example: Two Drawings from the Same Table topic. In the above the different geom fields are just copies of each other so the content of the drawings is the same. But, those geom fields could contain different values so the drawings which use the different geom fields could be different as well.
Suppose we decide to use Provinces 2 to change something in the table. Remember, the Provinces 2 drawing takes its geometry data from the Jeff field. We select the Centre region in France by ctrl-clicking it.
Next, we push the delete key. Good-bye, Centre. We may think that because the Provinces 2 drawing takes its geom data from the Jeff field all we have done is deleted the geom in the Jeff field for the Centre record in the table while leaving the other geom value in the Geom field for that record unmodified. But that is a mistake.
If we take a look at the Provinces drawing, which takes its geometry information from the Geom field, we see that Centre has disappeared in that drawing as well. How did that happen?
Pressing the Delete key with an object selected is a command to delete that object, which means deleting the record for that object. That is a very different thing than editing the value for one cell in the record to set that value to NULL. When we selected the Centre object and then deleted the Centre object from the Provinces 2 drawing we deleted the entire record for Centre.
If we want to remove the Centre geometry data from the Provinces 2 drawing while leaving the Centre geometry data in the Provinces drawing, that is easy to do: we simply set the value of the Jeff field to NULL for the Centre record. We will demonstrate how to do that.
Since it is good idea to make backups when working with data we do not want to accidentally lose, we begin by making a copy of the Provinces Table and naming the copy Provinces Table with Nulls. We could work with the Provinces Table directly, of course, but in most real life situations with tables that are not large we will simply make a copy by doing a quick Ctrl-C and Ctrl-V in the Project pane. We would also save the project under a backup name before making any radical changes.
We will select the Centre record in the illustrations below to make the record more visible. There is no need to actually select the record to edit it, but for the purpose of illustrations having a red selection background makes it easier to see.
Changing the value of a cell to NULL in a Manifold table is easy: right-click on the cell.
Choose Delete in the context menu.
If the record has been selected for editing (triangle icon in the row handle as seen above), we must press Ctrl-Enter to commit the edit.
If the record has not been selected for editing, the right-click followed by a Delete takes effect immediately.
The result is that the geom value in the Jeff field for the Centre record is set to NULL. See also the Example: Editing Records in a Table topic.
We now adjust the Provinces 2 drawing and the Provinces drawing to use the new table.
We open the properties dialog for the Provinces 2 drawing and we change the table to use to Provinces Table with Nulls. Press OK.
We open the properties dialog for the Provinces drawing and we change the table to use to Provinces Table with Nulls. Press OK.
Looking at the two drawings side by side we see that Centre has disappeared from Provinces 2 but is still in place in Provinces. When a geom has a NULL value the drawing shows nothing as there is no object to show for that record.
We can remove another region by changing to NULL the value for that region's record in the Jeff field.
For example, we change the value of the Jeff field to NULL for the Champagne-Ardenne record.
Instantly, in the Provinces 2 drawing the Champagne-Ardenne area object disappears while remaining unchanged, as expected, in the Provinces drawing.
We can illustrate how the two drawings use two different geometry fields in the same table using the diagram below:
The properties of each drawing and the table tell the drawings what to do:
In most cases drawings we use will take data from a table that has only one geom field. But in some cases it might make sense to have more than one geom field in a table. For example, a table that has geom fields showing regions of France as areas might have a second geom field that contains a point showing the location of the capital city of that region.
Suppose we would like to restore Centre and Champagne-Ardenne geometry to the Jeff field. How can we do that given there is no undo? We can copy the geom data from the Geom field, where it remains unchanged.
We begin by ctrl-clicking the Center record and the Champagne-Ardenne record to select them.
With the focus on the table window, in the Transform pane we choose the Geom field. We then double-click the Copy template to launch it in the Transform pane.
In the Copy template we choose geometry as the Use option.
In the Result destination box, from the pull down menu we choose the Jeff field.
We check the Transform selection only box.
Press Transform.
The template copies the geometry from the Geom field into the Jeff field, but only for all selected records. We can see in the table the values have been copied.
The Provinces 2 drawing is immediately updated with Centre and the Champagne-Ardenne region restored.
Copy and Paste - In the above we restored the original geometry values in the Jeff field by using the Transform pane to Copy the geometry values of the Geom field into the Jeff field, checking the Transform selection only box so the copy applied only to selected records.
Another way to do the same thing is to right-click onto the Geom field cell for the desired record, choose Copy in the context menu, and to then right-click onto the Jeff field cell for that record and choose Paste. That is a useful technique to restore geometry that has been edited in error. For example, suppose we plan on editing some objects in a drawing. First, in the project pane we copy the drawing's table and paste it, to make a backup copy of the table. Next, we edit the drawing as desired. If we make a mistake in editing some particular object, we can open the backup copy of the drawing's table, right-click onto the Geom cell for the object that was wrongly edited, choose Copy and then in the working table for the drawing we are editing we can Paste into the Geom cell for that same object. That will restore the object.
Multiple records - Some of the illustrations of tables show more than one record for various regions. Why is that? GIS data will often use multiple records for each area that makes up a particular region. For example, the region of Bretagne (known in England as Brittany) includes many islands, each of which is a separate area object in this data.
Provinces vs. Regions - The illustrations in this topic use data from the US government, which show the regions of France as they were before 1 January 2016, when the regions in France were reduced from 22 to 13. Centre is the same it was with just a change of name.
The drawing is called Provinces and not Regions because it was clipped out of a larger data set showing provincial boundaries for the entire world. Around the world sub-national divisions such as US states or French regions are called many different things, but the word provinces seems to have become a reasonably generic word that militaries and others engaged in mapping often use. State is rarely used because in many cultures it is a synonym for country and thus does not capture the notion of the administrative sub-units of a given country.
Centre vs. Centre-Val de Loire - The region referred to as Centre in this topic was called Centre until 2015, when the new name of Centre-Val de Loire took effect, perhaps in an effort to boost tourism to the genuinely wonderful valley of the Loire river, home to what is perhaps the largest concentration of classic chateaux anywhere in the world. To this day, everyone still calls the region Centre.
Example: Editing Records in a Table - How to edit the contents of an existing record using mouse and keyboard.
Example: Draw Lines, Areas and Points - Simple example of using basic mouse moves to add points, lines and areas to a drawing.
Example: Repair a Wrong Edit using a Backup - How to quickly make a backup table and to then copy and paste geometry from that table to repair errors made when editing objects. This technique is a life-saver when edits go astray.
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: 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: 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 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.