Skip to main content
deleted 1 characters in body
Source Link
Stev_k
  • 6.7k
  • 2
  • 35
  • 48

What you will need to do is write a MapBasic script something like the following.

Firstly, query your table. If you have co-ordinates stored as numbers in the table, the query will be something like this:

select x_column, y_column from yourTable [where condition] asinto MyQuery

Otherwise you need something like:

select CentroidX(yourTable.obj), CentroidY(yourTable.obj) from yourTable [where condition] asinto MyQuery

Then you need to iterate over the rows using Fetch statements. Then you can draw a polygon based on that point. The following is based on the Fetch() and Create Object() sections of the Mapinfo manual, and will probably have to be extensively altered to suit your case. In particular you may have to pay attention to co-ordinate systems if your data is not already projected in metres:

Fetch First From MyQuery
Do While Not EOT(MyQuery) 
    
                  Dim obj_region As Object 
Dim x(5), y(5) As Integer
Dim i As Integer 
x(1) = MyQuery.col1
y(1) = MyQuery.col2
x(2) = x(1) + 200
y(2) = y(1)
x(3) = x(1) + 200
y(3) = y(1) + 200
x(4) = x(1)
y(4) = y(1) + 200
x(5) = x(1)
y(5) = y(1)
' First, create an empty region object 
Create Region Into Variable obj_region 0 

' Now add nodes to populate the object: 
For i = 1 to 5 
Alter Object obj_region Node Add ( x(i), y(i) ) 
Next 

' Now store the object in the Sites table: 
Insert Into YourNewTable(Object) Values (obj_region)

    Fetch Next From MyQuery
Loop 

What you will need to do is write a MapBasic script something like the following.

Firstly, query your table. If you have co-ordinates stored as numbers in the table, the query will be something like this:

select x_column, y_column from yourTable [where condition] as MyQuery

Otherwise you need something like:

select CentroidX(yourTable.obj), CentroidY(yourTable.obj) [where condition] as MyQuery

Then you need to iterate over the rows using Fetch statements. Then you can draw a polygon based on that point. The following is based on the Fetch() and Create Object() sections of the Mapinfo manual, and will probably have to be extensively altered to suit your case. In particular you may have to pay attention to co-ordinate systems if your data is not already projected in metres:

Fetch First From MyQuery
Do While Not EOT(MyQuery) 
    
                  Dim obj_region As Object 
Dim x(5), y(5) As Integer
Dim i As Integer 
x(1) = MyQuery.col1
y(1) = MyQuery.col2
x(2) = x(1) + 200
y(2) = y(1)
x(3) = x(1) + 200
y(3) = y(1) + 200
x(4) = x(1)
y(4) = y(1) + 200
x(5) = x(1)
y(5) = y(1)
' First, create an empty region object 
Create Region Into Variable obj_region 0 

' Now add nodes to populate the object: 
For i = 1 to 5 
Alter Object obj_region Node Add ( x(i), y(i) ) 
Next 

' Now store the object in the Sites table: 
Insert Into YourNewTable(Object) Values (obj_region)

    Fetch Next From MyQuery
Loop 

What you will need to do is write a MapBasic script something like the following.

Firstly, query your table. If you have co-ordinates stored as numbers in the table, the query will be something like this:

select x_column, y_column from yourTable [where condition] into MyQuery

Otherwise you need something like:

select CentroidX(obj), CentroidY(obj) from yourTable [where condition] into MyQuery

Then you need to iterate over the rows using Fetch statements. Then you can draw a polygon based on that point. The following is based on the Fetch() and Create Object() sections of the Mapinfo manual, and will probably have to be extensively altered to suit your case. In particular you may have to pay attention to co-ordinate systems if your data is not already projected in metres:

Fetch First From MyQuery
Do While Not EOT(MyQuery) 
    
                  Dim obj_region As Object 
Dim x(5), y(5) As Integer
Dim i As Integer 
x(1) = MyQuery.col1
y(1) = MyQuery.col2
x(2) = x(1) + 200
y(2) = y(1)
x(3) = x(1) + 200
y(3) = y(1) + 200
x(4) = x(1)
y(4) = y(1) + 200
x(5) = x(1)
y(5) = y(1)
' First, create an empty region object 
Create Region Into Variable obj_region 0 

' Now add nodes to populate the object: 
For i = 1 to 5 
Alter Object obj_region Node Add ( x(i), y(i) ) 
Next 

' Now store the object in the Sites table: 
Insert Into YourNewTable(Object) Values (obj_region)

    Fetch Next From MyQuery
Loop 
Source Link
Stev_k
  • 6.7k
  • 2
  • 35
  • 48

What you will need to do is write a MapBasic script something like the following.

Firstly, query your table. If you have co-ordinates stored as numbers in the table, the query will be something like this:

select x_column, y_column from yourTable [where condition] as MyQuery

Otherwise you need something like:

select CentroidX(yourTable.obj), CentroidY(yourTable.obj) [where condition] as MyQuery

Then you need to iterate over the rows using Fetch statements. Then you can draw a polygon based on that point. The following is based on the Fetch() and Create Object() sections of the Mapinfo manual, and will probably have to be extensively altered to suit your case. In particular you may have to pay attention to co-ordinate systems if your data is not already projected in metres:

Fetch First From MyQuery
Do While Not EOT(MyQuery) 
    
                  Dim obj_region As Object 
Dim x(5), y(5) As Integer
Dim i As Integer 
x(1) = MyQuery.col1
y(1) = MyQuery.col2
x(2) = x(1) + 200
y(2) = y(1)
x(3) = x(1) + 200
y(3) = y(1) + 200
x(4) = x(1)
y(4) = y(1) + 200
x(5) = x(1)
y(5) = y(1)
' First, create an empty region object 
Create Region Into Variable obj_region 0 

' Now add nodes to populate the object: 
For i = 1 to 5 
Alter Object obj_region Node Add ( x(i), y(i) ) 
Next 

' Now store the object in the Sites table: 
Insert Into YourNewTable(Object) Values (obj_region)

    Fetch Next From MyQuery
Loop