MapInfo Pro

Expand all | Collapse all

MapInfo Monday: Creating and modifying Vector Grids

  • 1.  MapInfo Monday: Creating and modifying Vector Grids

    Posted 12-07-2020 06:42
      |   view attached
    In this #MapInfoMonday post, I will show you how you can use the  Grid Maker tool to create vector grids of a given size for a dedicated area.

    I will also show you how you can use specific functions in MapCAD to move and rotate your grid. MapCAD is an add-in that adds CAD-like functionality to MapInfo Pro. It has more than 30 different features for creating and modifying spatial data.

    This specific use case comes from Adrijana who responded to an earlier #MapInfoMonday post. Adrijana is looking​​ for a way to divide a risen bed into 30 cm grid cells as that is the distance between the flowers in each direction.

    Create the Vector Grid

    The first step is to create a vector grid for our area. In the map below, you can see the risen bed as the red polygon.

    That is the area I need to create a vector grid for.

    From the Tools window, make sure Grid Maker has been loaded and then double-click on the tool to launch it.

    You will see the Grid Maker dialog appear.

    Change these settings:
    • Distance between lines: In my case, I change this to 0.3 meters
    • Smoothness: I changed smoothness to 1 but as the grid cells are very small you could also change it to 0.
    • New Table: I picked a different location for the vector grid file
    • Projection: Make sure to switch to the same coordinate system as the table holding your area of interest. Also, note that as we are using small areas it is recommended to use a table with a bounded coordinate system where the resolution is higher than the typical 10 cm.
    Make sure that the option Select Area from Map has been checked. This allows you to draw a rectangle that you want the grid to cover.

    Now hit the OK button, and use the tool that you have been given to draw a rectangle in the map window.

    When you have drawn the rectangle, the Grid Maker dialog will appear again but this time it will show the coordinates from the rectangle you drew.

    Hit OK to accept the new extents and get the vector grid created.

    In the map window below, you can see the vector grid I ended up creating.

    Move the Vector Grid

    Now it is time to adjust the vector grid to the existing polygon.

    The first step is to move it so that the lower-left grid cells match up with the left corner of the existing polygon. It is not that important to use the lower-left grid cell. That depends on the existing polygon. The important thing is that you align a corner of a grid cell to a node in the existing polygon.

    When creating the grid, you could have snapped the extent of the vector grid to that node in the existing polygon. That would have made this step unnecessary - at least for my specific polygon.

    I will also recommend creating the vector grid in an area where it doesn't overlap the point on your existing polygon. If it does overlap, it can be hard to snap to the exact point.

    1. Make sure the add-in MapCAD has been loaded as we will be using tools from this add-in.
    2. Make sure the vector grid layer is editable
    3. Zoom into the map so that you can see the lower-left corner of the vector grid and the left corner of the existing polygon.
    4. Right-click the vector grid layer and select Select All from the context menu to select all the records in the vector grid table.
    5. From the Spatial table, in the Edit group, select the tool Move Along from the Transform dropdown.
    6. Hit the s key to turn on the snap feature. You can see that the word SNAP appears in the statusbar.
    7. Left-click in the corner of the vector grid cells and hold down the left mouse button, drag a line to the left corner of the existing polygon and let go of the mouse button.

    Now MapCAD moves the vector grid cells to the new position. In the map below, you can see the moved vector grid cells.

    Rotate the Vector Grid

    In this example, the risen bed is rotated and we want to match this rotation in the vector grid cells.

    First, we need to calculate the rotation. MapCAD has a tool for this: Calculate Direction. It gives you the direction of a line or polygon segment when you click on it.

    Select the tool Calculate Direction from the Calculate dropdown in the Edit group on the Spatial tab.

    Click on the segment you want to get the direction for. In the map below, you can see I have marked the polygon segment, I click on with an orange arrow.

    In the Calculate Direction dialog, I can see the direction and I can also store it for later use when clicking on the Store button.

    Now I have calculated the direction and I am ready to rotate the vector grid cells.

    1. Make sure the layer with the vector grid cells is editable
    2. Right-click the vector grid layer and select Select All from the context menu to select all the records in the vector grid table.
    3. From the Spatial table, in the Edit group, select the tool Rotate Object (MapCAD) from the Transform dropdown.
    4. Activate snap if you haven't done this already: Hit the s key to turn on the snap feature. You can see that the word SNAP appears in the statusbar.
    5. With the tool, click on the left corner of the existing polygon to mark the rotation point that you want to rotate the vector grid cells around.
    6. In the dialog Rotation Angle, select the stored value from the popupmenu with the angles, and then hit the Left button to rotate the vector grid cells counter-clockwise. 
    7. Hit OK to close the dialog.

    In the map above, you can see how the vector grid cells now how the same rotation as the existing polygon.

    Delete Grid Cells outside the existing polygon

    The final step in my example is to delete the vector grid cells that are outside the risen bed.

    Using the Layer List, make sure the layer with the risen bed (the existing polygon) is on top of the vector grid cell layer.

    From the Mini Map Toolbar, select the Boundary Selection tool from the Select splitbutton and click inside the existing polygon. This will select all the vector grid cells inside the polygon. More precisely, all the vector grid cells with a centroid inside the polygon.

    Now use Invert Selection to select all the other records and hit the Delete key on your keyboard to delete these.

    The final result looks like this

    I hope you have found this interesting and informative. The tools in MapCAD add a lot of capability to MapInfo Pro when it comes to creating and editing spatial objects.

    I have attached a PDF document with more tips and tricks on editing data in MapInfo Pro.

    Any suggestions on topics for an upcoming #MapInfoMonday article are most welcomed.


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

    Attachment(s)



  • 2.  RE: MapInfo Monday: Creating and modifying Vector Grids

    Posted 12-16-2020 04:18
    Thank you for this article Peter, once again. It is very useful and even more useful was the attachment on the bottom. Now I can finally fill table records automatically. :)
    So, I'll ask here the same question that I have asked Peter about grids.
    In the example above (raised flowerbeds) we said that the distance in all directions is 30cm, which means width is 30cm and length is 30cm. What if the width and length are different? Let's say width is 30cm and length is 45cm.
    Anybody has any solutions?
    Many thanks,
    Adrijana (MapInfo beginner willing to learn and develop)

    ------------------------------
    Adrijana Grujić
    Slough Borough Council
    SLOUGH
    ------------------------------



  • 3.  RE: MapInfo Monday: Creating and modifying Vector Grids

    Posted 12-21-2020 03:28

    HI Adrijana 

    As I mentioned to you earlier I haven't come across a Grid tool that lets you create grids where the length and height is not the same.

    Here's one option for you:

    1. Draw a line aligned with the long part of your raised flowerbed
    2. Copy and paste this line, and then rotate it 90 degrees so that it is perpendicular to the first line
    3. Now for these two lines repeat this until you have covered the entire raised flowerbed:
      1. Copy and paste the line
      2. Use Move Along from Spatial, Edit, Transform to move the copied line 30 or 45 cm. Trace the perpendicular line to get the angle.
    4. Once you have created lines across your raised flowerbed you can use Enclose from Spatial, Create, Regions to create polygons where the lines create enclosed areas. You'd have to select all the lines that you want to use as input for the Enclose operation first

    I hope this makes a bit sense to you



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



  • 4.  RE: MapInfo Monday: Creating and modifying Vector Grids

    Posted 12-22-2020 09:01

    Peter

    I was racking my brains trying to think where I had seen a dialog to create different horizontal and vertical spacings - It's in the Gridline function! Add Gridline to Map allows you to enter different spacings.

    Alas, these are just lines and you cannot select, copy or snap to. If only.....



    ------------------------------
    John Ievers
    CDR Group
    Hope Valley, United Kingdom
    ------------------------------