MapInfo Pro

 View Only
  • 1.  MapInfo Monday: Creating Outside Buffers on Polygons

    Employee
    Posted 11-06-2023 02:41

    Happy #MapInfoMonday 

    Today's post is driven by a question from @Mette Kramer Langgaard from SEGES. She is creating buffers around agricultural fields in Denmark, some 600,000 of them. She is however only interested in the buffer lying outside of the field. She doesn't want to have the actual field included in the result.

    She is looking for a buffer outside the existing polygon where the inside of the buffer has been erased.

    When creating buffers using Buffer Table from the Buffer dropdown on the Spatial tab, you will get buffers that also include the input object.
    When using this process, you will be asked to create a new table or use an existing table, specify the buffer settings, and how to handle the data aggregation.
    The resulting buffers will look like this. As you can see these buffers also cover the input objects, the lakes.
    There is a way to create "Outside Buffers" in MapInfo Pro. Well, there are probably more ways but I'll show you one way.
    First, you want to create a copy of your input table so that you don't overwrite your existing data. I named my table Lake Buffer. You can of course name if what you want. Make sure to open this table as we want to work with this table.
    I added this new table to my map and set the override style to a red-striped region style. As you can see, the Lake BUffer objects currently are identical to the Lake Objects.
    From the Table tab, I click on the SQL dropdown and click on the SQL control to open the SQL Window. We will use the SQL Window to run the update statement.
    From the New dropdown, I click on Update Statement to get the structure of an update statement.
    This is the base structure of an update statement. You update some table by setting some column equal to some expression:
    Update some_table Set some_column = some_expression
    Let's start by setting the table we want to update. Position your cursor after Update and either type in the table name or select it from the Table list just above the entry field.
    You can get help writing your statement using the IntelliSense feature that is built into the SQL Window. Type a few letters of what you want to write, and then hit Ctrl+Space on the keyboard. A list will now appear allowing you to select the word you are looking for. I started typing a function name and I can now select it from the list and insert it into the entry field.
    If the function inserts the function, it will also include the list of parameters that the function expects. This can be very helpful as you don't have to write it yourself.
    I now just have to fill in the missing pieces for the CartesianBuffer function: a resolution of 36 for a full circle and a buffer width of 100 meters. If you are using lat/long data, you should use Buffer instead of CartesianBuffer.
    The expression above is similar to what you would get if you were using the Buffer Table method discussed above. So we need to modify this slightly.
    We want to remove the existing polygon from this polygon. In MapInfo terminology, this is called erase. And so is the function that can help us do this: Erase().
    The Erase() function takes two parameters: the input object and the erase object. Our buffer will be the input object and the existing polygon will be the erase object.
    The resulting statement will look like this: 
    Update Lake_Buffer
    Set OBJ = Erase(CartesianBuffer(obj, 36, 100, "m"), obj)
    Notice that the SQL Window will give you hints on errors in your statements while you type. These errors will be shown in red at the bottom of the SQL Window next to the green checkmark.
    Hit Run to execute your statement and see the result.
    Below you can see how the resulting buffers don't overlap the original lakes.
    It may be a bit easier to see here where I have selected a few of the buffers.
    One thing to note is that it's only the object that the buffer is based on that will be removed from the resulting buffer. The buffer does overlap other input objects/lakes.
    You can read more about the SQL Window that was added to MapInfo Pro v2019. Here you can read more on creating buffers in MapInfo Pro


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


  • 2.  RE: MapInfo Monday: Creating Outside Buffers on Polygons

    Employee
    Posted 04-25-2024 01:47

    Here is a video running through the process described above



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