MapInfo Pro

 View Only
  • 1.  MapInfo Monday: Working with M & Z Values on Objects in MapInfo Pro v2023

    Employee
    Posted 09-13-2023 04:30
    Edited by Peter Møller 09-14-2023 05:21

    Happy #MapInfoMonday! And yes, the calendar shows Wednesday but during the release week for MapInfo Pro v2023, we decided to do #MapInfoMonday articles all week long!

    Our Native TAB format has supported M and Z values for a long while, but we haven't done much to make this accessible to you. You have been able to use MapBasic to inspect M & Z values on objects brought into MapInfo Pro through formats like GeoJSON, ESRI Shape, and others.

    With MapInfo Pro v2023, we have extended this in several ways.

    What benefits does Support for M & Z Values bring?

    The support for M & Z values allows you to assign two attributes at the node level. Until now, attributes have been assigned at the record level which meant that the entire object would hold a given value. With M & Z support, you can assign one or two values to the individual node of a polyline or polygon. This means the value can vary along your object.

    A couple of examples where M & Z values can be useful. Imagine you are a fiber optic company laying down fibers. When you measure these, you also capture the elevation along the fiber. Until now, you would have to store that elevation in a separate table of points where the Z value would be stored in a column. With support for M & Z values, you can store the elevation on the node of the polyline.

    The next step is to visualize your data in 3D. here you will be able to take advantage of the elevation stored on the nodes and position the fiber at the measured elevation. This should position your fiber lines underground.

    It can of course also be lines hanging in the air like the example you can see in the 3D Map below.

    Support for M & Z Values

    Before you can take advantage of storing M & Z values in a MapInfo TAB file, the table needs to be configured to support M & Z. You do this in the New Table Structure dialog when you create the table. You will find the Support M/Z option just above the Projections... button.

    If you have an existing table that you want to alter so that I will support M and Z, you can save a copy of the table, and in the Save Copy of Table As dialog, check the Support M/Z option.
    In the Table List window, you can quickly see if a table supports M/Z or not. The tables that do, use an icon with more color to it adding some perspective to the small drawing. The tables that don't support M/Z, are grey and flat in their appearance. In the image below, the tables Streams and Lakes don't support M/Z values.
    If you double-click on an object to bring up the Object Info dialog, this dialog will show if that specific object has been assigned M and/or Z values. Below you can see an example of the Polyline Object dialog where the selected polyline has Z values assigned to it. If you double-click on a point object with Z values, the Point Object dialog will also show the actual Z value.
    Keep in mind that even though a table supports M and Z values, all objects in that specific table might not have been assigned any of these values. The Has Z option in the dialog above means that the currently selected polyline has Z values assigned to one or more nodes. The polyline next to the selected may support M and Z values but might not have been assigned any yet. In that case, the Has Z option would be unchecked.

    MapBasic Support for M/Z Values

    In this section of the article, I will highlight the existing and new MapBasic functions and statements that can help you work with M and Z values on objects. We have for a long time been able to get to these values through MapBasic. The new thing is that we now also allow you to set or change these values.

    At a Table Level

    At a table level, you will be able to get and set if the table supports M and Z values. The Set option refers to creating a new table and saving a copy of a table.
    When saving a copy of a table, the support for M/Z is controlled by the SupportMZ option. If you leave out this option, the new table will inherit this setting from the original table. Alternatively, you can use the SupportMZ option followed by either On or Off to control if you want the table to support (On) or not to support (Off) M/Z values. Below you can see an example where I explicitly set the table to support M/Z values.
    Commit Table Rain_Water_Pipe As "C:\Sewer\Rain Water Pipe ZM.TAB" TYPE NATIVEX Charset "UTF-8" SupportMZ On
    Note that Support for M/Z values is built into both the two Native TAB formats, the classic Native format as well as the Extended NativeX format.
    When you create a new table, you specify the support for M/Z when you make the table mappable through the Create Map statement. You control this through the SupportMZ option similar to what you saw with Commit Table. Below is an example where I have created a new table and now want to make it mappable using the coordinate system of another open table. I also use the SupportMZ option to force the table to support M/Z. If I leave out the SupportMZ option, it will inherit the settings from the table I refer to.
    Create Map For Rain_Water_Pipe_ZM CoordSys Table Rain_Water_Pipe SupportMZ On

    At an Object Level

    You can read the M and Z details from an object using these functions.
    The function ObjectInfo() can tell you if a given spatial object supports M or Z values using the attributes OBJ_INFO_HAS_M and OBJ_INFO_HAS_Z. You need to check this before reading these values.
    To get to the actual values for point objects, use the function ObjectGeography() and the attributes OBJ_GEO_POINTM and OBJ_GEO_POINTZ.
    To get to the values on nodes on polylines and polygons, first use the functions ObjectNodeHasM() and ObjectNodeHasZ() to determine if the specific node has been assigned an M/Z value. If a value has been assigned, you can get to that value through the functions ObjectNodeM() and ObjectNodeZ(). Each of these functions takes an object, the segment/polygon number, and the node number as input.
    To set the M and Z values, you have to use the Alter Object statement. For point objects, you must use the Geography clause in combination with these attributes: 

    OBJ_GEO_POINTM and OBJ_GEO_POINTM. Here's an example for setting the Z value:

    Alter Object oOutput Geography OBJ_GEO_POINTZ, fZ

    For polylines and polygons, you must use the Node clause with the Alter Object statement and the Set Position option to specify values on existing nodes. Here is another example where I set the M value on an existing node. Notice how I omit the parameters for X, Y, and Z in this case as I don't want to change those.

    Alter Object oOutput Node Set Position nSegment, nNode (, , , fM)

    Hopefully this gives you some ideas on how to start using MapBasic to work with the Z and M values. I will also highlight that the source code for the DrawTools add-in which I will address in a moment can be found on GitHub. This may provide you with some additional resources for getting started. DrawTools takes advantage of a module - OBJECTMZLib - in the Common MapBasic libraries that also can be found on GitHub.The OBJECTMZLib holds functions that allow you to update a specific object with M and/or Z values. It also has functions for Offsetting objects in XYZ.

    Support for M/Z Values in DrawTools

    The add-in DrawTools - which can be found and installed from the MapInfo Marketplace - comes with several features that allow you to start working with M and Z values on your object.
    It allows you to assign M and/or Z values to existing objects in a table, you can offset existing objects in XYZ, and you can update nodes on polylines and polygons using a node table. The node table can also be created using DrawTools allowing you to assign for example Z values to the nodes from a digital elevation model and then bring those values back onto the nodes.
    You can read more about these capabilities in this article: DrawTools.

    Known Limitations

    Only polygons, polylines, points, and multipoint objects support M & Z values.

    Many object processing tools do not support M & Z values and will be disabled if the editable layer supports M & Z values. That's tools like Erase, Erase Outside, and others that modify your spatial object typically using another spatial object. This has been put in place to not lose the M 6 Z values assigned to the objects being processed. Object Processing can still be done via MapBasic statements but it will be up to the developer to handle potential M & Z values.

    We will also be looking into adding Z/M support to EFAL, GDAL and our MIF/MID format.

    Give it a try

    If you want to give the new version of MapInfo Pro a try, grab a 30-day trial version and take it out for a spin. We would love your feedback!

    As I mentioned above this is one of several #MapInfoMonday articles about the new features of MapInfo Pro v2023. Stay tuned for more!



    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------



  • 2.  RE: MapInfo Monday: Working with M & Z Values on Objects in MapInfo Pro v2023

    Posted 09-14-2023 03:27

    A couple of questions:

    1) Does MIF now support M/Z values?

    2) If the old TAB format has supported it for many years, how do you create such a table from scratch, pre-2023? I remember to have seen it mentioned in the MFAL library, but never looked into it. It has a type called CSYS_MZ_INFO. EFAL seems to have functions for it too.

    3) Do you have a sample table to download?



    ------------------------------
    Uffe Kousgaard
    ROUTEWARE
    Roskilde
    ------------------------------



  • 3.  RE: MapInfo Monday: Working with M & Z Values on Objects in MapInfo Pro v2023

    Employee
    Posted 09-14-2023 05:26
      |   view attached

    Hi Uffe,

    Thanks for these follow-up questions.

    1) I have added that to the original post. We still need to add this support to EFAL, GDAL, and the MIF/MID format

    2) This may be a question for @Bob Fortin.

    3) I have attached a table with powerlines where the nodes have been assigned a Z value

    Thanks

    Peter



    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------

    Attachment(s)

    zip
    Power Cable.zip   2 KB 1 version


  • 4.  RE: MapInfo Monday: Working with M & Z Values on Objects in MapInfo Pro v2023

    Employee
    Posted 09-14-2023 10:52

    re: #2 -- The support was there before, but only used when caching Z/M values upon opening shapefiles or geopackage and more recently OGR tables such as geojson. There was no way to create a table from scratch until this release.

    -Bob



    ------------------------------
    Bob Fortin
    Software Architect and Distinguished Engineer
    MapInfo Pro Development Team
    ------------------------------