MapInfo Pro

 View Only
  • 1.  Mapbasic Cleaning Script

    Employee
    Posted 05-08-2023 13:25
    Edited by Anthony Puckett 05-08-2023 13:42
      |   view attached

    Greetings Mapinfo Pro's

    Our team has inherited a production process which makes use of a "manual" cleaning step within Mapinfo via a Mapbasic script.
    We're not sure if running that script is necessary or not.  Our hope is that we could eliminate this manual step from our process as this breaks the tidy automated build chain.
         
    Here's a brief explanation of the process:
    Census Polygons are added to a PostGIS db.
    We run our own in-house geometry and attribution QC checks on the data, fix any errors (I can provide details on these checks if it helps understanding).
    Extract the cleaned data into tab/xtab format
    Run that Mapbasic script on that extract
    Zip it back up, send to QC, ship to customer

    What I'm looking to understand is what is happening in the Mapbasic script.
    How do I know when it's completed successfully, failed, or if error's remain? 
    Are we duplicating effort here since we do our own geometry checks prior to extracting from PostGIS in to TAB..
    OR.. is the act of extracting from PostGIS into TAB potentially creating geometry errors, invalid geometry, gaps, overlaps, etc?

    Script attached in .txt file.

    Thanks 
    Anthony



    ------------------------------
    Anthony Puckett
    Pitney Bowes
    White River Junction VT
    ------------------------------

    Attachment(s)

    txt
    cleaning_step.txt   3 KB 1 version


  • 2.  RE: Mapbasic Cleaning Script

    Employee
    Posted 05-09-2023 02:36

    Hi Anthony

    Your script basically runs these three statements on each table:

    1. Alter table tabName ( modify code Char(10), areaname Char(100), type Char(3) )
    2. Objects Clean From Selection Overlap
    3. Create Index On tabName (code)

    1. It changes the width of these three columns: code, areaname, and type.

    2. It runs Objects Clean to fix potential spatial data issues, see more details on the process:

    Objects Clean statement (from the MapBasic Help)

    The objects in the input tablename are first checked for various data problems and inconsistencies, such as self-intersections, overlaps, and gaps. Self-intersecting regions in the form of a figure 8 will be changed into a region containing two polygons that touch each other at a single point. Regions containing spikes will have the spike portion removed. The resulting cleaned object will replace the original input object.

    If the Overlap keyword is included, then overlapping areas will be removed from regions. The portion of the overlap will be removed from all overlapping regions except the one with the largest area.

    Note: Objects Clean removes the overlap when one object is completely inside another. This is an exception to the rule of "biggest object wins". If one object is completely inside another object, then the object that is inside remains, and a hole is punched in the containing object. The result does not contain any overlaps.

    Gaps are enclosed areas where no region object currently exists. In a boundary table, most regions abut other regions and share a common boundary. Just as there should be no overlaps between the regions, there should also be no gaps between the regions. In some cases, both these boundary gaps and holes are legitimate for the data. An example of this would be the Great Lakes in the World map, which separate parts of Canada from the USA. Most gaps that are data problems occur because adjacent boundaries do not have common boundaries that completely align. These gap areas are generally small.

    3. It creates an index on the column code.


    The script doesn't log much details, and the log that it creates is just printed to the Message window inside MapInfo Pro and so lost when you shut down MapInfo Pro.

    If you already do your topological checks in PostGIS, it could seem that this is doing the same. Do you know why this process was put in place?



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



  • 3.  RE: Mapbasic Cleaning Script

    Employee
    Posted 05-11-2023 09:08

    Hi Peter,

    Thankyou, this was exactly the information we were looking for.  

    For the Index created on column CODE, is that an attribution index or spatial index?

    Anthony



    ------------------------------
    Anthony Puckett
    Pitney Bowes
    White River Junction VT
    ------------------------------



  • 4.  RE: Mapbasic Cleaning Script

    Employee
    Posted 05-12-2023 02:28

    That's an attribution index.It makes it easier to search for specific values in this column and join other tables to this table using this column.

    The spatial index will always be part of a MapInfo Tab File.



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



  • 5.  RE: Mapbasic Cleaning Script

    Employee
    Posted 05-12-2023 09:59

    Excellent. Thanks again Peter!



    ------------------------------
    Anthony Puckett
    Pitney Bowes
    White River Junction VT
    ------------------------------