MapInfo Pro

Expand all | Collapse all

Write a MapBasic script to construct polygons where actual x, y is unknown

Mohammad Khan09-21-2017 03:49

  • 1.  Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-21-2017 02:12

    ?I need to construct numerous polygons to represent road segments (road assets) and have more than 1000 to do. I have a road centreline and a script that will plot points at known intervals along this line say every 10 or 100m. I need to write a script, if possible, that will create a polygon of say 5m wide either side of the centreline and between say 0 and 350m along the centreline and then repeat to create another polygon from 350 to 500m long at 5m either side of the centreline. Is this possible?

    Regards, Angelene

    email: awright@southburnett.qld.gov.au



  • 2.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-20-2017 23:29
    Hi Amita That’s great, thank you! Regards Angelene Angelene Wright Asset/GIS Officer South Burnett Regional Council PO Box 336 Kingaroy QLD 4610 ' 07 4189 9537 • awright@southburnett.qld.gov.au : www.southburnett.qld.gov.au [Description: Description: sbrcBar] DISCLAIMER: This electronic mail message is intended only for the addressee and may contain confidential information. If you are not the addressee, you are notified that any transmission, distribution or photocopying of this email is strictly prohibited. The confidentiality attached to this email is not waived, lost or destroyed by reasons of a mistaken delivery to you. The information contained in this email transmission may also be subject to Right to Information and Information Privacy legislation.


  • 3.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-21-2017 02:01

    Hi Angelene,

    This is very much possible as we can write mapbasic script to create buffer of 5m on the road centreline. I need one clarity on this and that is are we trying to create one polygon for each road segment or is it that we have a road segment that needs to have multiple polygons for that as you mentioned 0 to 350, 350 to 500.

    Thanks,

    Md. Aslam Khan



  • 4.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-21-2017 02:38
    Hi Md Aslam Khan Thanks for asking for clarification. Please see attached screenshot. It will be multiple polygons per length of road. So I have around 1400 roads and each of these needs to be comprised of segments. Some road segments might be from 0-500m, then 500-1075, 1075-3025 etc while another road might be 0-275, 275-620, 620-987 etc. And having said that I have just realised that a script may not be possible because of that variation ? arghhh… Angelene Angelene Wright Asset/GIS Officer South Burnett Regional Council PO Box 336 Kingaroy QLD 4610 ' 07 4189 9537 • awright@southburnett.qld.gov.au : www.southburnett.qld.gov.au [Description: Description: sbrcBar] DISCLAIMER: This electronic mail message is intended only for the addressee and may contain confidential information. If you are not the addressee, you are notified that any transmission, distribution or photocopying of this email is strictly prohibited. The confidentiality attached to this email is not waived, lost or destroyed by reasons of a mistaken delivery to you. The information contained in this email transmission may also be subject to Right to Information and Information Privacy legislation.


  • 5.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-21-2017 03:26

    Hi Angelene,

    Thanks for the clarification. I am unable to find the snapshot though.

    I am attaching a snapshot of my undurstanding to your query. A road always comprises of numerous segments and they vary in length and that is not a problem when it comes to writing a mapbasic script.

    In my snapshot I have taken account of a single road named ABC which is having four segments. If we need a 5m buffer for each of the segments than it is doable.

    Thanks,

    Md. Aslam Khan



  • 6.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-21-2017 03:49
      |   view attached

    Here goes my attachment ...



  • 7.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-21-2017 18:38
    Hi Mohammad Yes that’s what I’m after though the edges look like they have a champfer? The polygons will need to have clean 90° edges. I’m guessing there is a cost involved in you writing this? Could you please advise? Many thanks! Angelene Angelene Wright Asset/GIS Officer South Burnett Regional Council PO Box 336 Kingaroy QLD 4610 ' 07 4189 9537 • awright@southburnett.qld.gov.au : www.southburnett.qld.gov.au [Description: Description: sbrcBar] DISCLAIMER: This electronic mail message is intended only for the addressee and may contain confidential information. If you are not the addressee, you are notified that any transmission, distribution or photocopying of this email is strictly prohibited. The confidentiality attached to this email is not waived, lost or destroyed by reasons of a mistaken delivery to you. The information contained in this email transmission may also be subject to Right to Information and Information Privacy legislation.


  • 8.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-22-2017 02:05

    Hi Angelene,

    Here is the approach that will do the job for you.

    First you need to get hold of the road segments by querying by the road name and then loop through all the segments one by one. When you have the segment inside the loop, you can create a buffer around it using Buffer function as in the snippet.

    Dim o_line, o_polygon As Object 

    o_line = line_seg.obj

    o_polygon = Buffer( o_line, 10, 5, "m") 

     

    Function Description:

    Buffer( inputobject, resolution, width, unit_name )

    inputobject is an object expression.

    resolution is a SmallInt value representing the number of nodes per circle at each corner.

    width is a float value representing the radius of the buffer; if width is negative, and if inputobject is a closed object, the object returned represents an object smaller than the original object. If the width is negative, and the object is a linear object (line, polyline, arc) or a point, then the absolute value of width is used to produce a positive buffer.

    unit_name is the name of the distance unit (e.g., "mi" for miles, "km" for kilometers) used by width.

     

    Please let me know if this helps you out or you need any further assistance.

    Thanks,

    Md. Aslam Khan



  • 9.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-22-2017 02:56
    Thank you so much Mohammed! I’ll get stuck into it next week and let you know how I go! Have a great weekend! Regards Angelene Angelene Wright Asset/GIS Officer South Burnett Regional Council PO Box 336 Kingaroy QLD 4610 ' 07 4189 9537 • awright@southburnett.qld.gov.au : www.southburnett.qld.gov.au [Description: Description: sbrcBar] DISCLAIMER: This electronic mail message is intended only for the addressee and may contain confidential information. If you are not the addressee, you are notified that any transmission, distribution or photocopying of this email is strictly prohibited. The confidentiality attached to this email is not waived, lost or destroyed by reasons of a mistaken delivery to you. The information contained in this email transmission may also be subject to Right to Information and Information Privacy legislation.


  • 10.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-22-2017 06:37
      |   view attached

    Angelene,

    There might also be a different approach to solving your case as you are looking for clean edges but it can be quite tricky to get right especially where the road is turning.

    You can see the principles of the method in the image below.PerpendicularLines

    The idea is to use the individual segments as a base line and then create two points perpendicular to the base line. These points will become the nodes in the new polygon around your road segments.

    @Uffe Kousgaard? has a neat little tool called Toolbox that come with sourcecode: http://www.routeware.dk/toolbox.php. In the source code (AddNodes.mb) you can find the algorythms for calculating the offset points - the feature is called Add Nodes.

     



  • 11.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-25-2017 18:35
    Hi Peter Thanks very much! You’ve and Mohammed have been so helpful. I’m new to scripting so this enormously helpful to me. Kind Regards Angelene Angelene Wright Asset/GIS Officer South Burnett Regional Council PO Box 336 Kingaroy QLD 4610 ' 07 4189 9537 • awright@southburnett.qld.gov.au : www.southburnett.qld.gov.au [Description: Description: sbrcBar] DISCLAIMER: This electronic mail message is intended only for the addressee and may contain confidential information. If you are not the addressee, you are notified that any transmission, distribution or photocopying of this email is strictly prohibited. The confidentiality attached to this email is not waived, lost or destroyed by reasons of a mistaken delivery to you. The information contained in this email transmission may also be subject to Right to Information and Information Privacy legislation.


  • 12.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-25-2017 18:58
    Peter, I’m unable to open the downloaded file? It has a 7z file extension? Angelene Angelene Wright Asset/GIS Officer South Burnett Regional Council PO Box 336 Kingaroy QLD 4610 ' 07 4189 9537 • awright@southburnett.qld.gov.au : www.southburnett.qld.gov.au [Description: Description: sbrcBar] DISCLAIMER: This electronic mail message is intended only for the addressee and may contain confidential information. If you are not the addressee, you are notified that any transmission, distribution or photocopying of this email is strictly prohibited. The confidentiality attached to this email is not waived, lost or destroyed by reasons of a mistaken delivery to you. The information contained in this email transmission may also be subject to Right to Information and Information Privacy legislation.


  • 13.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-26-2017 01:58

    Hi Angelene,

    The downloaded file is with the name toolbox.7z. You need to extract it by doing a right click on it and then going for to Extract to toolbox option. Please install winrar if you dont have that installed. You will now have a folder with toolbox, get into it and you will have toolbox.mbx and toolbox64.mbx. Double click on any of them according to the Mapinfo version installed and it will be loaded up in mapinfo.

    Thanks,

    Md. Aslam Khan



  • 14.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-26-2017 03:39

    @Angelene Wright?  - Here is the direct link: http://www.routeware2.dk/toolbox.7z

    Click on the link (or copy past into browser) and it will download automatically.



  • 15.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Posted 09-27-2017 02:34
    Thanks Kobi. I didn’t have WinRAR installed which appears to be the issue. Regards Angelene Angelene Wright Asset/GIS Officer South Burnett Regional Council PO Box 336 Kingaroy QLD 4610 ' 07 4189 9537 • awright@southburnett.qld.gov.au : www.southburnett.qld.gov.au [Description: Description: sbrcBar] DISCLAIMER: This electronic mail message is intended only for the addressee and may contain confidential information. If you are not the addressee, you are notified that any transmission, distribution or photocopying of this email is strictly prohibited. The confidentiality attached to this email is not waived, lost or destroyed by reasons of a mistaken delivery to you. The information contained in this email transmission may also be subject to Right to Information and Information Privacy legislation.


  • 16.  RE: Write a MapBasic script to construct polygons where actual x, y is unknown

    Moderator
    Posted 08-05-2019 22:50
    Hi Angelene,

    Greetings!
    I hope you got the resolution of your query.
    Please mark the best answer by selecting "Make Best Answer" in the Reply menu.
    It will help us and other users save their time.

    For more information click here.

    Regards

    ------------------------------
    Aakash Singh
    Pitney Bowes Software India Pvt. Lt
    NOIDA
    ------------------------------