I have a grid which is made up of 100*100 cells. I want each cell to be identified by its x (1 to 100) and y (1 to 100) value . For example the cell on the top left corner must be Identified as (1,1) and the cell on the bottom right corner be identified as cell (100,100). There is a polyline which overlap some of these grid cells. I want to extract the (x,y) of each overlapped cell.

How can I do it in ArcMap?(Without python)


This would be much easier to do using python/arcpy...

Anyhow, here is a model builder approach (with a python snippet in field calculator [couldn't help it])

Build a model that looks something like this:

enter image description here

The model uses the following tools.

  • Con - set all raster cells to a single value
  • Raster to Polygon - Converts raster extent to polygon
  • Get Raster Properties - used to retrieve row count, column count, cell size, lower left corner coordinates.
  • Calculate Values - creates an origin point using lower left coordinates. Set Data Type to Point. Output gets fed into Grid Index Features.

enter image description here

  • Grid Index Features - creates a grid based on raster extent, column count, row count and lower left coordinates. Set polygon width/height to be the same as input raster cell size
  • Add Field - Add two fields CELL_ROW and CELL_COL to the output from grid index features.
  • Calculate Field - Calculates values for CELL_ROW and CELL_COL

Row and column positions are calculated using values from the PageNumber field generated by the Grid Index Features tool.

To get cell row position, divide PageNumber by the total number of rows then add 1, for rows where the PageNumber is not a multiple of total rows. Where PageNumber is a multiple of the total rows, cell row position is found by dividing the PageNumber by the row count. See graphic below.

enter image description here

Cell column position is given by PageNumber%column_count. if the modulus expression evaluates to zero, then cell column position = row_count.

enter image description here

The steps above yield (tested on a 100*100 grid, 1m cell size):

enter image description here

At this stage, you can plug in the rest of your processing steps. Use your polyline to select overlapping cells and take it from there..

  • Thanks Nxaunxau for your response. I have couple of questions.It would be great if you could answer my questions. 1- Why did you put page number between !! and rowcount between %% in the calculate field? 2-why did you fill both expression field and code block filed ? (I mean, Is it necessary to fill expression field ). 3-Why did you use %row_count% and %column_count% in the expression field and replace them with nrows and ncol in definition line in python code? and how should I change the code if my first cell (1,1) is at bottom left ? Cheers – Mike May 30 '16 at 12:26
  • 1
    @Mike - exclamations marks tell python that pageNumber is an attribute in the input table. Refer to this page for more detail. The % notation tells the calculator to retrieve the value from the model variable referenced between the %% symbols. Read here about inline variable substitution – Nxaunxau May 30 '16 at 12:37
  • 1
    @Mike - In the Grid Index Feature Tool, tick the Start labelling from Origin check box. That should start labelling from the bottom left corner – Nxaunxau May 30 '16 at 12:41
  • 1
    @Mike - nrows and ncols are variables defined within the row_value and col_value functions. Refer to this and this for function definitions – Nxaunxau May 30 '16 at 12:48

The number of possible solutions are somewhat limited without the use of Python. However, I'd suggest using the Fishnet function with polygons as output. Make sure that the fishnet cells covers the corresponding cell in your grid (this can take a few trials while creating the fishnet).

You now need to enumerate your polygons. Copypaste values from excel in an edit session to get the 1-100 in a field in the attribute table. Selection via the GUI is probably a good help here. However, some manual checking/value entering can probably not be avoided if Python is out of the question.

When this is done you can easily convert your polygons to a grid if need be, or just use it as a vector layer and query as is.

In fact, using it in vector format is probably easier. A spatial join between your polylines and these fishnet polygons should get you an attribute table field populated with the overlapping polygons' IDs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.