I have a raster which shows the probability that a cell will be used (raster_Use). I also have a points file that shows mortality locations (points_Morts). I have overlain points_Morts onto raster_Use and extracted the probability of use for each mortality location. I also need to extract the cell ID from raster_Use for each mortality point in points_Morts. I've tried converting the raster_Use to a polygon but I've received the following error:

ERROR 000864 Input raster: The input is not within the defined domain. ERROR 000863: Invalid GP data type.

I read in another thread that a solution is to change the raster values from a float to an integer. I've tried that but the resulting raster only contained 0s because the values are between 0 and 1 and thus rounding down to 0. My next thought is to create another raster that's identical to raster_Use that contains 1...n unique values and then extract those values to the points_Morts file. I can't figure out how to do so.

Does anyone have an idea of how to do so?

@Luke provided a great answer, but unfortunately it doesn't quite work. To expand on why it doesn't, identifying the column and row numbers creates a key for the points file but there still isn't a key for all cells in raster_Use. So I know which cells points_Morts falls in, however, I don't know the ID for cells in raster_Use that don't contain points from points_Morts. I tried converting raster_Use to a points object and then implemented @Luke's solution, but the Raster to Points tool creates 4 points for every raster cell instead of 1. Ideally, I would like to start with a cell (e.g., the lower left corner cell) and assign it a value of 1 then continue onto the next cell assigning a value in ascending order.

I misunderstood Luke's question on "why?" I'm doing this. I am validating the predictive ability of a model. Raster_Use is my prediction and points_morts is my validation dataset. I'm validating my model by grouping the cells from raster_Use into 20 equal-area bins. Expected use is the predicted value for each grid cell. I place these cells into 20 equal-area bins and then summed by bin and standardize to 1. Observed use is the frequency of mortality locations in each grid cell, summed by bin and then standardized to 1. After that, I'll use linear regression to regress observed vs predicted use where the slope of the regression relationship between observed and expected provides an assessment of the predictive abilities of the model.


You can calculate an incrementing ID based on the row and column numbers which will uniquely identify the cell that the points are in.

Add a column to your point feature class named CELLID (type = long integer).

In the field calculator, select the python parser, tick the show code-block box and in the pre-logic script code section enter:

import arcpy

def calc_cell_id(shape, raster):

    raster = arcpy.Raster(raster)
    xmin = raster.extent.XMin
    ymax = raster.extent.YMax
    px = raster.meanCellWidth
    py = raster.meanCellHeight
    ncols = raster.width

    col = int(abs((xmin - shape.getPart(0).X) / px))
    row = int(abs((ymax - shape.getPart(0).Y) / -py))

    id = row * ncols + col + 1

    return id

In the "CELLID = " section enter:


For example:

enter image description here

To create a raster with the same values, open the ArcMap python window and enter the following:

raster = arcpy.Raster("NAME_OF_YOUR_RASTER_LAYER")

arcpy.env.extent = raster
arcpy.env.mask = raster
arcpy.env.cellSize = raster
arcpy.env.extent = raster

ncols = raster.width

arcpy.gp.singleoutputmapalgebra("$$ROWMAP * %s + $$COLMAP + 1" % ncols, "path/to/save/your/output_unique_id_raster")
| improve this answer | |
  • Hi, Luke. Thanks for the help! Your suggestion worked great. I was able to generate the row and the column value for each cell. The only issue is that I don't have a key to relate the points file back to the raster. Is there same way to create another raster that has 1..n unique cell values or a polygon that has the unique row and column values that you've created here? Thanks again. – Matt Nov 20 '18 at 16:43
  • @MattGould, can you edit your question and provide more info about why – user2856 Nov 20 '18 at 19:38
  • see edit in the question up top. Best. – Matt Nov 20 '18 at 22:14
  • @MattGould your edit still just says what you want to do, not why. I can generate a unique ID grid but in over twenty years of working with raster data in Esri software, I have only ever come across one situation where that was warranted. You can easily calculate which cols and rows don't have points without creating a raster as you know the total number of cols and rows and which ones have points. It may be that another way of thinkng/doing would be better. – user2856 Nov 20 '18 at 22:47
  • @MattGould see edit, but I do think you should consider if this is necessary... – user2856 Nov 21 '18 at 0:28

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.