MapInfo Pro Developers User Group

 View Only
  • 1.  Find the extent of a table

    Posted 01-16-2020 10:39
    (Apologies if this has been answered before. I couldn't find it in a search)

    We have a MapInfo vector table with Region objects in EPSG 3857. We want to know the min and max x and y extent over all objects in the table. But we get different answers depending on how we ask for the data.

    Set CoordSys Earth Projection 8, 74, "m", -159, 0, 0.9996, 500000, 0 Bounds (-7745844.29605, -9997964.94315) (8745844.29605, 9997964.94315)

    Print TableInfo(alias, TAB_INFO_MINX)
    // Returns 801229.23

    SELECT * FROM alias WHERE obj INTO qTest NOSELECT
    Print TableInfo(qTest, TAB_INFO_MINX)
    // Returns 821069.75

    SELECT MIN(ObjectGeography(obj,  OBJ_GEO_MINX)) "MINX" FROM alias WHERE obj INTO qTest NOSELECT
    Browse * From qTest
    // Returns 821069.75044454

    Why does TableInfo return a different value than looking for the MinX over all objects?

    ------------------------------
    Matthew Katinsky
    Senior GIS Programmer
    SCHLOSSER GEOGRAPHIC SYSTEMS

    ------------------------------


  • 2.  RE: Find the extent of a table

    Posted 01-16-2020 14:03
    Edited by Eric Blasenheim 01-16-2020 14:04
    Matt,
    One reason this could be happening is due to edits.  As you edit a table, the code takes care of assuring that any geometry inserted or updated outside the current max bounds increases those bounds. This is what tableinfo() on the base table reports. However, if subsequent edits make the bounds smaller, the code does not retrieve every existing record and see if the bounds should be shortened.  If you pack the table or save it as another table, then the calculation start over.
    The query table has its own separate bounds which is of the data contained in it. 

    I will note some special parts of your case that may not be relevant but are a bit special.
    First of all you are setting the coordsys to a bounded version of UTM ​Zone 4, I think.  This is not the default so geometries can definitely be clipped.
    Secondly, by setting the coordsys to something different than the original table, which you said was in Popular Mercator, the answers you are getting are going through coordinate system transformation to return the answers. 
    So a question back to you would be if you get this discrepancy if you set the coordsys to popular Mercator?

    Set  CoordSys Earth Projection 10, 157, "m", 0



    ------------------------------
    Eric Blasenheim
    Spectrum Spatial Technical Product Manager
    Troy, NY
    ------------------------------



  • 3.  RE: Find the extent of a table

    Posted 01-16-2020 17:58
    I can see how TableInfo() bounds might exceed actual object bounds over time due to deletions. Thanks for that explanation.

    As for the bounds in the coordsys clause, the table itself was defined using that very bounded coordsys clause. However we did try the code again setting the current coordsys to Popular Mercatur WITHOUT bounds and got the same results. In fact, we then packed the table and tried it again and still got the same results. So given all that, can you think of a reason why TableInfo() produces a result that doesn't match the min/max over all the objects in the table?

    ------------------------------
    Matthew Katinsky
    Senior GIS Programmer
    SCHLOSSER GEOGRAPHIC SYSTEMS
    Montpelier VT
    ------------------------------



  • 4.  RE: Find the extent of a table

    Posted 01-16-2020 18:18
    The fact that it gave the same results using Popular Mercator make sense and is reassuring. The fact that packing the table did not change ​the result does seem odd unless the graphic (geometry) packing did not happen.  Maybe share the data?

    ------------------------------
    Eric Blasenheim
    Spectrum Spatial Technical Product Manager
    Troy, NY
    ------------------------------



  • 5.  RE: Find the extent of a table

    Posted 01-16-2020 20:44
    Hi Matthew,

    Have you checked the coordinates to find out which of those MinX coordinates is actually correct?  What does the CoordSys Bounds Manager tool return?

    ------------------------------
    James Nolet
    Dooley Mitchell & Morrison Pty Ltd
    Mentone, VIC, Australia
    ------------------------------



  • 6.  RE: Find the extent of a table

    Posted 02-04-2020 11:28
      |   view attached

    Sorry for the delay. I got a copy of the table from my coworker. It turns out that the table's native coordsys is UTM Zone 4, not Popular Mercator! Either I was misinformed or I wasn't paying attention. Regardless, we still seem to have a problem.

    I have uploaded the table so you can test this yourself. Despite its name, you will see as soon as you open it, it is not confidential data.

    set coordsys earth projection 8, 74, 7, -159, 0, 0.9996, 500000, 0
    print format$( tableinfo(confidentialpartnerfootprints,20), "0.000000")
    => This returns 801229.226583

    select * from confidentialpartnerfootprints where obj into qtest
    print format$( tableinfo(qtest,20), "0.000000")
    => This returns 821069.750444






    ------------------------------
    Matthew Katinsky
    Senior GIS Programmer
    SCHLOSSER GEOGRAPHIC SYSTEMS
    Montpelier VT
    ------------------------------

    Attachment(s)



  • 7.  RE: Find the extent of a table

    Posted 02-04-2020 13:13
    Matt,
    This data example exhibits exactly what I wrote about earlier. The overall table bounds are much bigger than the actual data most likely due to previous edits. When I save a copy of the table or pack the table, the bounds become exactly what the query table shows. Are you seeing something different from this?



    ------------------------------
    Eric Blasenheim
    Spectrum Spatial Technical Product Manager
    Troy, NY
    ------------------------------



  • 8.  RE: Find the extent of a table

    Posted 02-05-2020 09:23
    I see the same behavior! Thank you Eric. Next time, I will know better than to trust my minions when they tell me what the CoordSys is.

    ------------------------------
    Matthew Katinsky
    Senior GIS Programmer
    SCHLOSSER GEOGRAPHIC SYSTEMS
    Montpelier VT
    ------------------------------



  • 9.  RE: Find the extent of a table

    Posted 02-05-2020 14:53
    Two final comments on this.
    One is that the enlarged bounds can be from something that was never saved. That is, you can create or modify some data than enlarges the bounds.  Then change your mind or change again and then save your tab file. The bounds will probably be the largest it ever was.  So if this is critical then packing the table is a good idea. 

    Secondly (a very minor point but)  I noticed that in MapBasic you chose  to ​use format$ to output text that has more decimal places.  This is often a good idea when you are printing out numeric values that happen to be decimal degrees. However, in the cases here you are dealing with meters so having 6 decimals to the right on a meter is what, a micron? So these values are simply not real. 
    There is no problem in using them other than the confusion they cause in making long numbers that look impressive but do not represent any real precision.

    ------------------------------
    Eric Blasenheim
    Spectrum Spatial Technical Product Manager
    Troy, NY
    ------------------------------