Example: Transform Template Units

Templates in  the Transform pane often include parameter boxes using units of measure.  This example uses the Buffer template for geometry fields to show how to change units of measure quickly to whatever units are desired.


We open a map as seen below.   The map is in default Pseudo-Mercator projection.  It contains two layers: a background layer showing satellite photography from Bing and a Dot drawing layer that contains a dot.  Both layers are also in Pseudo-Mercator, the projection used by Bing and most other web servers.  


In front of the Capitoline Museum we see the plaza designed by Michelangelo in 1538, with an exact copy of the Roman bronze equestrian statue of the Emperor Marcus Aurelius in the center.



The green dot marks the spot where we intend to fly a small drone with a camera, to take close up photos of the statue.  We can get away with using a drone in the plaza, but not inside the museum where the original is on display.   


We purchased the drone in a budget electronics store in Kowloon: it is intended for indoor use and the instructions say we can control it with our smart phone using Bluetooth up to a distance of 30 something units.  The units are unclear since the printed  instructions are in Chinese.   We don't know if the 30 means 30 meters or 30 feet.   We will try different buffer sizes to see what "30" might imply for operational radius.


With the focus on the map window, in the Transform pane we choose the Dot layer and the Geom field.  We then double-click the Buffer template to launch it in the Transform pane.



In the Buffer template, we enter 30 for the Distance.  Given the Unit setting of Meter, that is a choice of 30 meters.   


For the Result destination, we choose New Field.   That will create a new geometry field in the same table that hosts data for the Dot layer.  We enter the name Geom buffer for the result, and we enter the name Buffer to use for the New drawing, that will visualize the geometry in the new Geom buffer field.


To see a preview of what the template will do, press the Preview button.



The buffer that will be created appears in a new preview layer, drawn in blue preview color above all other layers.  A blue preview caption bar at the top of the window reports the template that is being previewed.



If we would like to see what is below the preview layer, we can right-click the blue preview caption bar and choose 50% opacity, to show the preview layer with partial opacity, so layers below are partially visible.


If we like what we see, to apply the transform we press Transform.  



If we have the table open for the Dot drawing, we would see that a new Geom buffer field appears in the drawing, with an area object created for the buffer zone for the point in the Geom field.


A new drawing called Buffer appears in the Project pane.   We can drag and drop the new drawing into the map window.



In the illustration above, we have used the Layers pane to set opacity for the Buffer layer to 50%, and the Style pane to choose an orange-yellow color for the area fill color.  The layer contains a single, circular area with a radius of 30 meters from the point.   We can see that if our drone can be controlled at a distance of 30 meters from where we will stand we will have no problem flying it about the statue.  But what if the "30" in our drone's user manual means 30 feet?


The Transform pane still shows all settings used to create the Geom buffer field and the new Buffer drawing.   We start with those.



To change the units of measure to feet, in the very long pull down menu for the Unit box we choose Foot.


Next, we will change the result destination, since we do not need to create a new field and a new drawing.   We can simply reuse the Geom buffer geometry field and the Buffer drawing created in the previous step.



From the pull down menu for the Result box, we choose Geom buffer, which now appears in the list of existing geometry fields.  



The buffer radius will now be computed as 30 feet, with the resulting buffer area stored in the existing Geom buffer field.    The existing Buffer drawing will automatically update to show that new geometry in the field that it visualizes.


To see a preview, press the Preview button.



The preview display remembers that we last set preview opacity to 50%, so it displays the preview with 50% opacity.   We can see the smaller size of the buffer that will be created using 30 feet as the buffer distance.


Press Transform.



Instantly, the Buffer layer in the map updates to show the new geometry, showing what a buffer of radius 30 feet would be.   Clearly, if the user manual for our drone means it can only be controlled up to 30 feet by Bluetooth, we must make sure to stand close to the statue.

Units Depend on Projection

The units of measure in the Unit box that are available for the Buffer template and other Transform templates depend on the type of projection (coordinate system) used by the source drawing.   There are basically two types of coordinate systems: those that use linear units of measure (meters, feet and other linear units), and those that use angular units of measure (degrees, radians or other angular units):



We can see that by switching the projection of the Dots drawing from Pseudo-Mercator, which uses linear units of measure, meters, for the coordinate system, to Latitude / Longitude, which uses angular units of measure, degrees, for the coordinate system.



 With the focus on the Dot layer in the map, in the Info pane we click the coordinate system picker button to choose a new coordinate system.  



 In the Reproject Component dialog that pops open, the default favorites and any other favorites we have added will appear in a list, along with a More... option to launch the full Coordinate System dialog.


We pick Latitude / Longitude, one of the two default favorites, and then in the Reproject Component dialog we click Update Component.



The Dot drawing is now in Latitude / Longitude projection.      


The Transform pane will automatically update to use angular units of measure in the Unit box for the Dot layer.    Angular units of measure are a huge pain in the neck to use for distances such as buffers.



For example, at the latitude of Rome, a single degree of latitude is approximately 111,000 meters, so 30 meters would be approximately 0.00027 degrees in North-South dimension.


We enter 0.00027 for the Distance box, with the Unit box set to Degree.   We also use New Field for the Result, creating a new Geom lat lon buffer field and a new Lat Lon Buffer drawing to visualize it.


Press Preview.



The image shows the distorted buffer created in Latitude / Longitude units but reprojected on the fly into the Pseudo-Mercator projection used by the map window.


Press Transform.


A new Lat Lon Buffer drawing appears in the Project pane.   We drag and drop the new drawing into the map.



In the illustration above we have styled the new Lat Lon Buffer drawing like the old Buffer drawing, and we have removed the old Buffer layer from the map.


The new buffer area appears as an ellipse.   That is because at the latitude of Rome, a degree of latitude (North-South distance) is approximately 111,000 meters, but a degree of longitude (East-West distance) is only approximately 84,000 meters.   A distance of 0.00027 degrees is smaller in East-West dimension than a distance of 0.00027 degrees is in North-South dimension when projected into the Pseudo-Mercator projection used by the map.


If we would like to see the buffer zone using degrees, we can reproject the map window into Latitude / Longitude.



The result, seen above, distorts the Bing satellite background, but when seen in Latitude / Longitude projection, where degrees are the same in both North-South and East-West dimensions, the buffer zone created at a distance of 0.00027 degrees in all directions from the dot is a circle.


Tech Tip:  Do not use Latitude / Longitude projection for layers in which buffers will be created.  Use a coordinate system that uses linear units of measure.  



List all units of measure - Transform templates often provide parameter boxes that have a list of all available units of measure, and coordinate system dialogs often do as well.  However, if we would like a list of all units of measure available we can use SQL:


TABLE CALL CoordUnits();


or more elegantly, with a field that indicates if the unit of measure is a radial unit suitable for latitude/longitude coordinate systems:



  StringJsonValue([value], 'Unit', true) AS [name],

  Coalesce(StringJsonBoolean([value], 'UnitLatLon', true), false) AS [latlon]

FROM CALL CoordUnits();



See Also



Transform Pane


Example: How Images use Tiles from Tables - An example showing how an image is made up from data stored in a table in tiles.


Example: Create Two Images From One Table - More than one image can show data from the same table, including from the same tile field.


Example: An Image using Computed Fields in a Table - How an image can be created from tiles where the data for the tiles is taken from a field that is computed on the fly.


SQL Example: Re-tile an Image using a Different Tile Size - Starting with an image that uses a tile size of 128 x 128 pixels this SQL example creates a copy of the image using 500 x 500 pixel tiles.


SQL Example: Kriging - We use SQL functions to create a raster terrain elevation image from vector contour lines in a drawing, using SQL functions for Kriging interpolation.


Example: Merge Images - A step-by-step example using the Merge Images command showing how to merge dozens of images showing SRTM terrain elevation data into one image, with various tricks for faster workflow as an experienced Manifold user would do the job.  After creating the new image we style it with a palette and use hill shading to better show terrain elevation.


Example: Contour Areas and Contour Lines - In this example we use the Contour Areas transform template in the Transform pane for images to create a drawing with vector areas showing height contours at desired altitude steps.   We color the areas using the attribute fields automatically created by the template.  Next, we apply a similar procedure using the Contour Lines transform template to create a drawing with vector lines showing height contours at the desired intervals.