﻿ Example: Create a Multipoint

# Example: Create a Multipoint

This topic provides two examples:  First we create a multipoint and then next we create a multipoint having two branches.

The purpose of this topic is to help teach the implementation of geometry in Manifold and other typical spatial packages using a somewhat unusual, highly counter-intuitive and (mercifully) rarely-met object type, the multipoint.  A multipoint combines what appear to be many separate points into a single multipoint object.

For most people and for most applications it is a really bad idea to use multipoints since every person when looking at a drawing that appears to have many separate points will, logically, think they are indeed separate points.  Most GIS users have never heard of a multipoint and are baffled when they encounter such things.

### Example: Create a Multipoint

This example shows how to create multipoints, which generally are a type of object that should not be used outside of very rare situations.   Because we might encounter such objects in imported data we should understand that they exist and how to work with them, hence this example.

In the Project pane we create a new drawing which by default is called Blank and uses a new, blank table called Blank Table.   We open the drawing.

In the main toolbar we choose Create Point and then we press Ctrl-? to open the New Object dialog

We click in the drawing to add points.   With each click a new previewed point appears and a row with the coordinates for that point appears in the dialog.

To add a multipoint we must change the action button from the default Add Point / Multiple Points to Add Point / Multipoint.

We then press the Add Point / Multipoint button to create those coordinates as a single point.

The dialog closes and what appears in the drawing seems to be several independent points.

But when we open the drawing's table we see that there is only a single record for a single point object.   The geom for that point object is a multipoint that consists of the coordinates we clicked.

It's obvious that using multipoints can cause confusion because the visual display of what seem to be multiple objects doesn't match the database reality of a single object in the table.  Almost always using multipoints is a bad idea instead of structuring data so that different points are indeed different records and thus different objects.

### Create a Multipoint with Two Branches

We will continue the theme of illustrating nuances of geometry by creating a point object which we should never in real life need to create, a multipoint that has two branches.   By doing so we see how to operate controls in the New Object dialog.

As before we create a blank drawing, choose the Create Point tool, open the New Object dialog and begin clicking into the drawing to create coordinates for points

After clicking three times to create coordinates we Shift-click to create a coordinate that is also the end of a branch.   Note that for the fourth record in the New Object dialog an asterisk * appears indicating it is the end of a branch.

We click three more times to create three more coordinates.

To create the previewed multipoint, we change the command button at the bottom of the dialog to Add Point / Multipoint and we press the Add Point / Multipoint button.

Seven points are created in the drawing.

Visually, they appear to be seven separate point objects but when we open the table for the drawing we see that only one point object was created.   All seven points that appear in the drawing are part of a single point object.

Visually the points in the drawing appear to be separate.   As a practical matter the way we would notice they are all part of the same point object is if we try to select one of them using a selection box and it is not selected.   If we use Shift-click and drag to draw a selection box that will select an object if any part of it falls within the box, then we would select all of the points involved in the multipoint.

We could also use SQL to find all points that have more than one coordinate in their geom:

SELECT * FROM [Table]

WHERE GeomIsPoint([Geom]) AND GeomCoordCount([Geom]) > 1;

That query will select all records for multipoints, whether or not they have multiple branches, for example, the multipoints created in this example and also in the preceding example.

To find only those multipoints that have multiple branches as in this example we can use the GeomBranchCount(<geom>) function in the query:

SELECT * FROM [Table]

WHERE GeomIsPoint([Geom]) AND GeomBranchCount([Geom]) > 1;

We do not need to check for more than one coordinate in the geom since if a point has more than one branch it also has more than one coordinate.

## Notes

Zillions of digits after the decimal point - Why are the coordinate numbers in the illustrations relatively short numbers like 199.5 or 177.5 but sometimes when we try to repeat this example the numbers have many digits after the decimal point as in the illustration above?   See the Notes in the New Object Dialog topic for a discussion.

Advice: the point of this example is not to recommend the use of multipoints but instead to teach a nuance which we may encounter when working with a data set that uses multipoints or multipoints with branches.   That such objects can exist is a side effect of the orthogonality and consistency of how geometry is defined for GIS purposes, but other than learning about such things to deal with situations where someone has chosen to use them, the risk of confusion and chaos from using multipoints is so great it is probably a better idea not to use them.

Drawings

Coordinates

New Object Dialog

Example: Draw Lines, Areas and Points - Simple example of using basic mouse moves to add points, lines and areas to a drawing.

Example: Trace an Area in a Map over an Image Background - In a map with a drawing layer above an image layer, create an area object in the drawing by tracing over the outlines of something seen in the image layer below.

Example: Create a Line using the New Object Dialog - Step by step creation of a line in a drawing using the New Object Dialog.

Example: Create a Line using Curved Segments - Creating a line made up from curvilinear geometry using the New Object Dialog.

Example: Create an Area with a Hole - Using the New Object Dialog, create an area in a drawing where the area includes one or more holes.  This is similar to how we create areas that have islands as part of the area.

Example: Create an Area with Holes and Islands - Using the New Object Dialog, create an area in a drawing where the area includes holes and also islands.