Thanks to the help of Uffe Kousgaard and Paul Smith I have my mapbasic code
updating (auto numbering) my grids cells from west to east and then down to
the next row to start the process again. 

Currently, I have 14000 grid cells created.  I need to update the attributes
for these in groups of 100 (10 grid cells across numbered 1-10 the next row
will be 11-20 etc. X 10 grid cells down) out of the 14000 total cells.  I
really don't want to manually enter a number in each of these grid cells.

|_|_|_|_|_|_|_|_|_|
|1|2|3|1|2|3|1|2|3|
|4|5|6|4|5|6|4|5|6|
|_|_|_|_|_|_|_|_|_|


Does anyone on the list have any ideas or suggestion on how I could
accomplish this.  I know very little about mapbasic.  Maybe the code I have
below can be modified to do this.  Thank you in advance.

Mike




Hi Michael,

Here is your revised Code. Just swapping the order of (For y = 0 to
iCellsDown - 1) AND (For x = 0 to iCellsRight - 1)

This changes the order the regions are drawn from Vertical to Horizontal
first (Left to Right)

Now simply changing the iLong +   to iLong -  (Changes from left to right
>>  right to left)

I hope this helps.

Paul

'///////////////////////////////////////////////////

Include "mapbasic.def"

Dim iCellsRight, iCellsDown, x, y, ID as Integer Dim temp_obj as Object Dim
iLong, iLat as Float

iCellsRight = 10
iCellsDown = 10
iLong = 145
iLat = 10

Create Table "grid_temp" (RecID Integer) file "c:\grid_temp.tab" TYPE NATIVE
Charset "WindowsLatin1" Create Map For grid_temp CoordSys Earth Projection
1, 62 Browse * From grid_temp Map From grid_temp Set Map Layer 1 Editable On


Set Style Brush MakeBrush(1,RED,-1)
Set Style Pen MakePen(1,4,RED)

For y = 0 to iCellsDown - 1   'Swap these
        For x = 0 to iCellsRight - 1  'Swap These

        Create Region Into Variable temp_obj 0

        Alter Object temp_obj Node Add ( iLong - 0.00125 * x, iLat + 0.00125
* y ) ' Change + to - to
        Alter Object temp_obj Node Add ( iLong - 0.00125 * (x+1), iLat +
0.00125 * y ) ' Change + to - to
        Alter Object temp_obj Node Add ( iLong - 0.00125 * (x+1), iLat +
0.00125 * (y+1) ) ' Change + to - to
        Alter Object temp_obj Node Add ( iLong - 0.00125 * x, iLat + 0.00125
*(y+1) ) ' Change + to - to

        Insert Into Grid_Temp (RecID, Obj) Values (ID, Temp_Obj)

        ID = ID+1

        Next
Next
Commit Table Grid_Temp

'///////////////////////////////////////////////////





-----Original Message-----
From: Michael Smith [mailto:[EMAIL PROTECTED]
Sent: Thursday, 20 January 2005 8:25 AM
To: mapinfo-l@lists.directionsmag.com
Subject: RE: MI-L auto increment polygons


 I have this piece of mapbasic code maybe someone can explain.  this code
creates grid cells beginning with the southwest corner of the grid and
autonumbers up and then to the right.  How can I change it so that the row
id numbers autonumber from right to left rather than from bottom to top.

*******************

Create Table "grid_temp" (RecID Integer) file "c:\grid_temp.tab" TYPE NATIVE
Charset "WindowsLatin1" Create Map For grid_temp CoordSys Earth Projection
1, 62 Browse * From grid_temp Map From grid_temp Set Map Layer 1 Editable On


Set Style Brush MakeBrush(1,RED,-1)
Set Style Pen MakePen(1,4,RED)


For x = 0 to iCellsRight - 1
        For y = 0 to iCellsDown -1

        Create Region Into Variable temp_obj 0

        Alter Object temp_obj Node Add ( iLong + 0.00125 * x, iLat + 0.00125
* y ) 
        Alter Object temp_obj Node Add ( iLong + 0.00125 * (x+1), iLat +
0.00125 * y ) 
        Alter Object temp_obj Node Add ( iLong + 0.00125 * (x+1), iLat +
0.00125 * (y+1) ) 
        Alter Object temp_obj Node Add ( iLong + 0.00125 * x, iLat + 0.00125
*
(y+1) ) 

        Insert Into Grid_Temp (RecID, Obj) Values (ID, Temp_Obj)

        ID = ID+1

        Next
Next

Commit Table Grid_Temp

*****************************************




-----Original Message-----
From: Michael Smith [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 19, 2005 3:26 PM
To: MapInfo-L@lists.directionsmag.com
Subject: MI-L auto increment polygons

Hi list,

I am trying to create a grid map (polygons) 4000 X 5000.  Grid cell sizes
are 4.5 seconds of latitude and 4.5 seconds of longitude.  Using Mapbasic, I
have created this grid (although I may need to redo it in order to
accomplish my goal).

I have to number these grids cells (polygons) in groups of one hundred - 10
grid cells X 10 grid cells.  In this 4000 X 5000 grid, there will several
groups of these 100 grid cells.  I really don't want to manually enter 1, 2,
3, etc. in each of the grid cells.

On this table I have tried -> table ->update column and entered "value =
rowid".  This works to autonumber all the grid cells, but the problem is
that it does put the autonumbers in the cells that I want them in.  I am
trying to explain the question but may not be making myself clear.  

If anyone has any suggestions or ideas on how to accomplish this, PLEASE
help me!  If I need to give more/better explaination let me know.  Thank you
in advance.

Mike


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 14965

Reply via email to