# Easy way to Create Vector Grid polygons?

We're currently using MapInfo & MapBasic to analyze daily tests results for planning purposes.For each test,exported result may contain empty values (say 999,we know Mapinfo has no NULL values),so we decided to maintain each result (by point values) by averaging and cleaning empty results for each parameters inside a square(piece of grid),that way results may not repeat at the same coordinates and separation of empty values.(Or you can say get results by grid where each grid contain how many points and joining results for each cell by averaging)

In this scenario,firstly we thought about creating these grids via gridmaker.mbx which is free tool for Mapinfo,but when the area is too large or the cell size is too small or even if grid maker has no chance to imply our algoritm that like in the following

We approach this problem by creating rectangles by 10 to 5000 meter values which are square cell sizes,and insert these values onto these tests via MBR or Convex polygon objects by checking out whether cell intersects these generated object from test.

The problem starts here even if we process these cells,generating results may last weeks,months even.So my question is likely in the title,so i ask a different and easy way to approach this problem.

Solutions,scenarios,algorithms you answer may not be solved only in mapinfo,but other tools as well.

• What version of MapInfo are you currently using?
– Mapperz
Aug 25, 2011 at 13:39
– Myra
Aug 25, 2011 at 13:57

An alternative approach would be to use a database engine (could be MapInfo) to analyse your result data and generate a file that could then be plotted in MapInfo as a vector grid:

Assuming Result data has a format like the following: X, Y, Value...

1. Decide on the cell size of your MapInfo vector grid
2. Truncate the X and Y coordinates to the nearest whole number of cell sizes
3. Summarise (group by) the truncated X and Y columns generating the summary data that you require - mean, count etc.
4. Transfer the summary into MapInfo and plot points from the truncated coordinates - these should plot in the lower left corner of each grid cell with data.
5. Convert the points into grid cell squares using the following MapBasic code (could be in a MBX, or from the MapBasic window):

`set coordsys table ResultPoints`
`update ResultPoints set obj = mbr(createline(centroidx(obj), centroidy(obj), centroidx(obj) + GridCellSize, centroidx(obj) + GridCellSize))`

(You need to substitute the value from step 1 into the second line in place of `GridCellSize`)

The result should be very similar to what you were aiming for originally.

• ,is it not the same approach truncating the coordinates to nearest whole number of cell sizes as you mentioned in step 2 with creating grid squares ?
– Myra
Sep 12, 2011 at 8:37
• The result would be the same with the two methods, but I think my approach should be considerably faster - firstly the data aggregation is done using a non-spatial query, and secondly, only the vector grid polygons containing data are generated. Sep 12, 2011 at 13:01
• How can i differ grids from each other for different regions,is there a logic that allow squares dont overlap like a regulation on plot regions ?
– Myra
Sep 14, 2011 at 12:09

You can increase limit on number of cells from 65000 to 1048576 & Define MAX_CELLS 20648881 in the gridmaker.mbx.

Or make smaller grids and then merge them.