# Question About Remove Excess Points in Polygons

26 views

### Dilan Gözdem Dolu

Jan 12, 2023, 3:17:57 PMJan 12
to MapInfo-L
Hello everyone,

How can i write my MapBasic code that erases redundant points along the edges on polygons and prints them to the screen?

### Peter Horsbøll Møller

Jan 13, 2023, 3:44:12 AMJan 13

It seems there are more of you who have been assigned a task 😊

I would suggest that you create a small application with a main procedure and a function that removes the redundant points.

In your main procedure you can update the obj for your table with the function. If you use the Selection as the table, you don’t need to ask the user what table to use.

And you can use the Input() function to prompt for the distance tolerance – or just hardcode it.

Remember to set the coordsys too

Use these statements:

• Declare Function
• Declare Sub
• Function
• Sub
• Update
• Set CoordSys
• Input

First you need to create a loop that runs through all the nodes in your polygon

Use these statements and functions:

• For Next or Do Until for you loop
• ObjectInfo() to query the number of segments and number of nodes in your polygon

For each node in each segment, you will have to create a line between the node before and after, and calculate the distance from the node to this line.

Use these functions and statements:

• ObjectNodeX() and ObjectNodeY()
• CreateLine()
• CreatePoint()
• ObjectDistance()

If the distance is smaller than your tolerance, you need to remove the node.

Use this statement:

• Alter Object

You may find the structure of the function OBJRemoveDuplicateNodes from the OBJLib helpful

Also there were some discussions on this topic last week on the MapInfo-L

Good luck – and feel free to come back with additional specific questions

Peter

Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

Sent: Thursday, 12 January 2023 21.07
Subject: [MI-L] Question About Remove Excess Points in Polygons

 This message originated Externally. Use proper judgement and caution with attachments, links, or responses.

Hello everyone,

How can i write my MapBasic code that erases redundant points along the edges on polygons and prints them to the screen?

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
To unsubscribe from this group, go to: