Question

Calculate cell distance between cells

  • 19 February 2019
  • 1 reply
  • 10 views

I want to calculate the cell distances between all cells within a feature class grid. Exactly the same as the game Minesweeper

I currently have the cells as a feature class within an esri file geodatabase, but can easily convert it to a raster grid.

I have included an example below. The original data contains 11000 cells with different labels but I have simplified in the example:

For each cell I want to find how many cells apart they are from all other cells.. Example here is for cell A2. I would then iterate this for every cell in the grid to produce the final csv.

I have attempted using cost distance tools within a GIS, but It's unable to cope with the data.

I have access to FME 2014, but looking through the help files I've been unable to find a way to do this.

Is anybody able to give me some guidance as to how this may be achieved?

 

Many thanks


1 reply

Userlevel 2
Badge +17

The position of a cell in the matrix can be specified by a pair of column index and row index. Assuming that positions of two cells are (column0, row0) and (column1, row1), according to the rule illustrated in your screenshot, I think the distance between them can be calculated with this pseudo expression.

distance = max(abs(column1 - column0), abs(row1 - row0))

Reply