Hi everyone,
I have two identical rasters, i use extent to put them on the same lower left corner but they havent the same shape. I want to get the size of my first raster to apply to my second.
Do you have any idea ?
Thank You.
Solved! Go to Solution.
I think i find what i was looking for, thank you guys for answering me.
i get 10 with this
So you have two identical rasters but they don't have the same shape? Sounds like they are not completely identical. Can you explain how the shapes differ? Are the extents the same, but the resolution (cell size and therefore rows and columns) of the rasters different? Why do you want to do this with Python (do you have a number of rasters to process in the same way?
As Xander indicates, they may differ in other ways, like cell size,
The rows and columns must also match. If they don't then you will have to use a Resample to replicate those.
If can get messy with a combination of extent, snap raster and sampling.
Outlining the purpose of what you are doing may lead to alternate procedures (ie using numpy)
Hi Paul,
What type of rasters are you working with (i.e. .TIF)? Check to see if the raster that is in the correct location contains a .aux.xml file in File Explorer. You can try copying this file and renaming it the identical raster.
In fact this is the same raster, but i did some processing on it.
I use arcpy.RasterToNumPyArray to use it like an array and finally i made the opposit way with arcpy.NumPyArrayToRaster.
But the default parameter for cell size is 1. I lose the cell size of my first raster.
I got this :
When converting back you have options for lower left corner, cell size and nodata values
NumPyArrayToRaster (in_array, {lower_left_corner}, {x_cell_size}, {y_cell_size}, {value_to_nodata})
Yes, in fact i would like to change xcell and ycell with the input cell size of my first raster.
Paul, next time, include the script you are using in your posts to help for provide targeted answers.
I think i find what i was looking for, thank you guys for answering me.
i get 10 with this