MapInfo Pro Developers User Group

 View Only
  • 1.  Import/convert WKT to TAB

    Posted 01-21-2018 09:53
      |   view attached

    Hi,

    I have a WKT file in CSV format that I need to convert to TAB and create polygons. I tried using @Peter Horsbøll Møller?'s MBX "WKT2MapInfo" but am getting the following error: No objects found in layer. when attempting to use the WKT column.

    Has anyone used this MBX successfully and could point me in the right direction or know of other solutions?

    I've also attached a sample CSV of the data I'm trying to convert.

    Thanks,

    Kobi

    Attachment(s)

    csv
    WKT_CSVSample.csv   1 KB 1 version


  • 2.  RE: Import/convert WKT to TAB

    Employee
    Posted 01-22-2018 03:09

    I had a look at your sample at I notice that the difference between your data in the data I had used before was a missing space between the feature type and the coordinate list:

    POLYGON((34.8136515627899 32.17252 ...

    versus

    POLYGON ((34.8136515627899 32.17252 ...

    I made a small modification to the tool and it can now also handle your WKT format. There is a new version of the tool available at Community Download: http://communitydownloads.pbinsight.com/code-exchange/download/wkt2mapinfo



  • 3.  RE: Import/convert WKT to TAB

    Posted 01-22-2018 08:44

    Thanks @Peter Horsbøll Møller?. I had a feeling there was something small that I didn't have quite right.

    I'm also honored to now have the update date as my birthday.

    Another small request, would it be possible to add a drop-down menu to select the spacial column instead of it having to be named WKT or GEO?

    Thanks again, great tool!



  • 4.  RE: Import/convert WKT to TAB

    Employee
    Posted 01-22-2018 09:04

    Happy birthday, Kobi! 🎂

    Sure, the source is out there so just add the dropdown 😀

    No, honestly, I have actually a few times myself thought why I didn't do that from the beginning so that's a good suggestion.

    But that would of course mean that the date will change and no longer match your birthday...



  • 5.  RE: Import/convert WKT to TAB

    Posted 01-23-2018 02:29

    Thanks @Peter Horsbøll Møller? :) I'm willing to give up the title for the drop down menu.

    Where is the source code located? I only see the MBX in the folder, not the MB.



  • 6.  RE: Import/convert WKT to TAB

    Employee
    Posted 01-23-2018 02:31

    Github is where I share the source code for most of the tools that I make available.

    Here you can find the sourcecode for WKT2MapInfo: https://github.com/PeterHorsbollMoller/mbWKT2MapInfo



  • 7.  RE: Import/convert WKT to TAB

    Posted 06-07-2021 10:13
    Edited by Nils Berthelsen 06-07-2021 10:14

    Hi Peter
    I recently tried to use the WKT2MapInfo tool with MapInfo v. 19.3.

    I tried to import a WKT-polygon using WKT2MapInfo (found here and on GitHub), but unfortunately it didn´t work at first.

    MI responded with a "configure table, index" error in line 408.

    Input string (UTM32 - epsg 25832 projection):

    WKT

    "POLYGON ((666125.14 6166965.8,666098.04 6166877.65,666281.91 6166891.67,666315.46 6166909.76,666359.13 6166912.2,666358.77 6166924.67,666522.96 6167003.67,666494.72 6167068.11,666418.99 6167108.22,666125.14 6166965.8))"



    Then i discovered, that the "old" sample file provided by Kobi had an extra column to the left.

    Therefore i added the following to my WKT-string, and then i got the expected result.

    index,WKT

    1,"POLYGON ((666125.14 6166965.8,666098.04 6166877.65,666281.91 6166891.67,666315.46 6166909.76,666359.13 6166912.2,666358.77 6166924.67,666522.96 6167003.67,666494.72 6167068.11,666418.99 6167108.22,666125.14 6166965.8))"

    After this small alteration, the polygon imported perfectly into MI after choosing the appropriate coordinate system.

    .






    ------------------------------
    Nils Berthelsen
    Region Sjælland
    Sorø
    ------------------------------