Select to view content in your preferred language

RASTER CELL X/Y VALUES

1556
6
08-23-2013 06:52 AM
anTonialcaraz
Frequent Contributor
Hi,

I'm trying to calculate the area of multiple rasters on a cell by cell basis, that is from decimal degrees to square meters.
I've put together an equation that calculates that (see attachment) but as I'm very new to python I'm having difficulties trying to get the X Min, X Max, Y Min, Y Max values for each cell into the equation.

Any tips and trick that I can use to accomplish the task would be greatly appreciated.

Thanks

Toni
Tags (2)
0 Kudos
6 Replies
RobertBorchert
Honored Contributor
I am not 100% on this but a raster can be broken down into a point feature and the entire cell is a single value.  The area of the cell is bespoken by the resolution of the raster.  Hence if the resolution is 2 foot the center of the cell (the x,y) would be 1 foot from each side at a 90 angle.  Pythagorean Theorem would then be used to determine the min/max of the x,y  of the cell.

Hi,

I'm trying to calculate the area of multiple rasters on a cell by cell basis, that is from decimal degrees to square meters.
I've put together an equation that calculates that (see attachment) but as I'm very new to python I'm having difficulties trying to get the X Min, X Max, Y Min, Y Max values for each cell into the equation.

Any tips and trick that I can use to accomplish the task would be greatly appreciated.

Thanks

Toni
0 Kudos
anTonialcaraz
Frequent Contributor
Thanks for the reply Robert.

As I'm dealing with Decimal Degrees here I'm not sure I would get the area right. The equation takes that into account.
I'm pretty sure there is a way in Python to call XY Min/Max for each cell so I can introduce those values into the equation.

many thanks

Toni
0 Kudos
JamesCrandall
MVP Alum
Not sure if this helps or hurts, but couldn't you:

1. Run RasterToPolygon_conversion to arrive at a polygon Feature Class.  http://resources.arcgis.com/en/help/main/10.1/index.html#/Raster_to_Polygon/001200000008000000/

2. Then go through a SearchCursor, set the shape extent for each row and this would get you the X Min, X Max, Y Min, Y Max values.  Perhaps you could just populate a list or data frame with which you could pass back to your process/calling application.

(sorry no working code to show on this one but you could probably whip something together pretty easily).
0 Kudos
anTonialcaraz
Frequent Contributor
Thanks a lot James. I had already considered this option.
Problem is that when I convert from raster to polygon some cells get merged together so I would lose the true area of several cells and I do need to get the area right for each cell prior to calculating volume.

Thanks

toni
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Alcaraz,

You can use the Fishnet tool to create a polygon fishnet using the extent and cell size of your raster.  You can then use the Search Cursor to return the xmin, ymin, xmax, and ymax of each polygon.

cursor = arcpy.SearchCursor(fc)
for row in cursor:
    print row.Shape.extent.XMin, row.Shape.extent.YMin, row.Shape.extent.XMax, row.Shape.extent.YMax

del cursor, row
0 Kudos
anTonialcaraz
Frequent Contributor
Thanks a lot Jake. That was very useful.

Toni
0 Kudos