how to create a square buffer around a point feature

53 views
Skip to first unread message

Dahram A.

unread,
Sep 10, 2025, 1:57:03 PM (11 days ago) Sep 10
to MapInfo-L
Dear MapInfo User,

Please help, how to create a square buffer around a point feature in MapInfo Pro ver. 21 ?

Regards,
Dahram A.

Peter Horne

unread,
Sep 11, 2025, 6:57:40 PM (10 days ago) Sep 11
to MapInfo-L
Hi Dahram,

Note  I am using V23, but pretty sure this should work in V21 as well
When using the buffer function change the number of segments to 4. See attached images.
Hope this helps.
Thx Peter 

pointBuffer_4lines.jpg
BufferFunction.jpg

Peter Horne

unread,
Sep 11, 2025, 8:42:00 PM (10 days ago) Sep 11
to MapInfo-L
Haven't played much with AI , but thought I would see what CHATGTP would come up with as answer to this problem. Interesting....

mapbasic program to draw square around a point
Chatgtp said:

Perfect — you want the square centered on a point rather than giving fixed coordinates. In MapBasic you can take a point’s X and Y, then compute the corners of the square from that center. Here’s a working example:

' Program: DrawSquareAroundPoint.mbx ' Purpose: Draw a square polygon around a given point 
 Include "mapbasic.def" Declare Sub Main Sub Main Dim x As Float, y As Float Dim halfSide As Float ' Example point coordinates x = 500 ' X coordinate of the point y = 500 ' Y coordinate of the point ' Half the side length of the square halfSide = 50 ' Create a table to store the square Create Table SquareTable ( ID Integer, obj obj ) File "SquareTable.TAB" Open Table "SquareTable" ' Insert square polygon centered on (x,y) Insert Into SquareTable (ID, obj) Values (1, CreatePolygon( _ x - halfSide, y - halfSide, _ x + halfSide, y - halfSide, _ x + halfSide, y + halfSide, _ x - halfSide, y + halfSide, _ x - halfSide, y - halfSide)) ' Add layer to current map Add Map Layer SquareTable End Sub
How it works:
  • (x,y) is your point.

  • halfSide controls the size of the square (so side length = 2 * halfSide).

  • The square is built by offsetting the point’s coordinates.

  • The polygon is explicitly closed by repeating the first coordinate at the end.

👉 Do you want this program to take the point from an existing MapInfo table (e.g., you click a point on the map), or is a fixed coordinate good enough?


Uffe Kousgaard

unread,
Sep 12, 2025, 2:01:36 AM (10 days ago) Sep 12
to mapi...@googlegroups.com
Hi,

Interesting yes, but it also doesn't compile.
1) You can not create a field called obj as part of create Table
2) There is no CreatePolygon function
3) Strange _ in the function call before the x values.

Here is an adapted version, which works. The MBR hack is from Peter Møller.



' Purpose: Draw a square polygon around a given point 
Include "mapbasic.def"

Declare Sub Main

Sub Main
Dim x As Float, y As Float
Dim halfSide As Float

' Example point coordinates

x = 50
' X coordinate of the point

y = 50
' Y coordinate of the point

' Half the side length of the square
halfSide = 1


' Create a table to store the square
Create Table SquareTable ( ID Integer) File "SquareTable.TAB"
Open Table "SquareTable"
Create Map for SquareTable


' Insert square polygon centered on (x,y)
Insert Into SquareTable (ID, obj) Values (1, MBR(CreateLine( x-halfSide, y-halfSide,x+halfSide, y+halfSide)))


' Add layer to current map
Add Map Layer SquareTable

End Sub 


Kind regards
Uffe Kousgaard
--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mapinfo-l/bc2fab96-dbbe-4f0c-8785-2912abf0c3e8n%40googlegroups.com.

Dahram A.

unread,
Sep 12, 2025, 6:16:31 AM (9 days ago) Sep 12
to mapi...@googlegroups.com
Hi Peter,

Thank you for your help.  
It works.  I make a 45 degree rotation to fix square position.

Regards,
Dahram A.


--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.

Dahram A.

unread,
Sep 12, 2025, 6:18:41 AM (9 days ago) Sep 12
to mapi...@googlegroups.com
Hi Uffe,

Thank you for your answer. 

Regards,
Dahram A.


Peter Horne

unread,
Sep 15, 2025, 5:59:54 PM (6 days ago) Sep 15
to MapInfo-L
Yeah Uffe, I realised it wouldn't compile, but AI will "refine" the result by telling it what errors you encounter when compiling. Probably will never give the absolute correct answer but gives a reasonable bag of bones to put some flesh on, if you don't know where to start. Won't ever replace expert knowledge though
Reply all
Reply to author
Forward
0 new messages