MapInfo Pro

 View Only

MapInfo Monday: Making DBMS Tables Mappable

  • 1.  MapInfo Monday: Making DBMS Tables Mappable

    Posted 01-22-2024 03:31

    Happy #MapInfoMonday!

    We have now created a connection to our spatial database and we have added the MapInfo_MapCatalog to the database too. Now we can start adding tables to the Map Catalog so that we can use these tables in MapInfo Pro.

    There are a couple of ways to get tables added to the Map Catalog. Let me start by stating that you don't need to add all tables to the Map Catalog. Tables with only attribute data and no spatial data don't have to be added to the Map Catalog to be opened in MapInfo Pro. You only need to add the tables that you want to use in MapInfo Pro and that hold a spatial component.

    You can add tables manually to the Map Catalog or through a script. This is a bit tricky as you need to ensure the values are right. This can be done and could be useful if you create new tables in the database using a batch process for example.

    A table will automatically get added to the Map Catalog with the correct attributes if you upload it to the database through a MapInfo tool, such as MapInfo Pro or MapInfo EasyLoader. We will cover this in a later article.

    If you already have tables with a spatial component in the database, you can use Make DBMS Table Mappable to add it to the Map Catalog. Let's dive a bit into this part.

    From the Database dropdown on the Table tab, click on Make DBMS Table Mappable.

    The Select Data Source dialog will now prompt you to select a Data Source to connect to the specific database. I'll select the data source we created earlier which connects us to the PostgreSQL/PostGIS database.
    If you already have a connection open, you will not be prompted to select the data source, MapInfo Pro will use the existing DBMS connection.
    If you have multiple DBMS connections open, you can right-click on the one you want to use from the Connections list in the Explorer Window, and from here select Make DBMS Table Mappable. As you can see you can work with your open DBMS connections directly from the Explorer Window.
    After selecting Make DBMS Table Mappable and opening a connection to a database, you will now be asked to select the table to make mappable from the Select DBMS Table dialog.
    First, ensure that the correct Schema has been selected at the top of the dialog. Normally MapInfo Pro will select the first schema from an alfabetically sorted list.
    You will now see a list of tables and views, that don't exist in the Map Catalog. If you don't see any tables listed, all your tables in the specific schema already exist in the Map Catalog.
    Now select the table that you want to make mappable and click on the Open button. I'll start with the addresses table.
    This will bring up the Make Table Mappable dialog. Some of the values have been selected based on details from the table. Others you will have to change yourself.
    The Index Type list will pick up any spatial column types in the table. In this specific case, it detected the sp_geometry column which is a spatial geometry column. The Index Type list is connected to the Index Column list, X Coordinate list, and Y Coordinate list. Depending on the Index Type you select one or more of these three lists will be enabled.
    Let me explain the Index Type values we see here:
    • PostGIS: This is a specific spatial index type that you only will see if you use a connection to a PostgreSQL database that also has the PostGIS extension.
    • MapInfo: This is a spatial type made up of three columns. An X Coordinate a Y Coordinate and an Index Column store a spatial index in the form of a string value.
    • XY Coordinates: This allows you to select two columns with coordinates which will get converted into a point when opened into MapInfo Pro.

    Be careful with the MapInfo type. This is rarely used and if used wrongly, you could overwrite another string value by selecting a random string column as your Index Column. For a true spatial database, you will mostly use the specific spatial format of the database, here PostGIS, and in some cases, you would use the XY Coordinate spatial index and seldom use the MapInfo Index Type.

    Once you are set on the Index Type, you can select the Object Type. This depends on the types of spatial objects you have in the database table. Mostly you would be able to set it to a single type (Point, Line, or Region). If you can, select the appropriate type. If the table could hold records with mixed types, select All from the list.

    This choice affects the type of Object Style you will be able to select. It doesn't set any rule on the database preventing you from adding other object types to the table when editing the table in MapInfo Pro or through another tool.

    If you check the Per Row Style option, you will also need to select a column holding the style details for the individual records. Again, make sure the column you select doesn't contain other attribute information. If you don't have a dedicated Style Column, uncheck the Per Row Style option. This option allows you to store different styles for each record. If you want all the records in the table to be rendered with the same style, make sure to uncheck the Per Row Style option.

    Finally, you should select a default Object Style for the table. The table will be rendered using the style when you open the table in MapInfo Pro. If you have checked the Per Row Style option, this default style will be used if the value in the Style Column is empty.

    For some tables, you will also have to specify the coordinate system using the Projection... button. For the PostGIS Index Type, MapInfo Pro will get the coordinate system from the Index Column.

    Now click on the OK Button to register this table in the Map Catalog.

    Hopefully, you will not be told that the table was made mappable.

    Now the Select DBMS Table dialog reappears and you can select another table to make mappable. If you have no more tables, you want to make mappable, click on the Cancel button in the Select DBMS Table dialog.

    When you add a table to the Map Catalog, it will get stored with several values telling MapInfo Pro how to open and render the objects.

    Here is the addresses table record, I just added to the Map Catalog. We will not go into detail with these values in this article but this gives you an idea of the values being stored in the Map Catalog when you make a table mappable.

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