Creating rasters with rectangular cells

5343
7
03-25-2015 09:29 AM
DavidMartin
Occasional Contributor II

I've been looking through the ArcGIS help documentation in order to try to understand my options for creating rasters with rectangular cells, as well as to identify where processes may fail to take account of input rasters with rectangular cells. I'm not sure if I've yet got the full list (can anyone add to it?), and also I've come across what appears to be a bug with one of them (details below).

 

Ways to create rasters with rectangular cells from scratch:

a/ Create a numpy array and use arcpy.NumPyArrayToRaster, specifying different x and y cell sizes.

BUG: While this creates an arcpy.Raster in memory which has the appropriate cell dimensions, nevertheless when you save this raster (using the save() method of arcpy.Raster) it reverts to square cell dimensions.

b/...?

 

Ways to create rasters with rectangular cells from existing rasters:

a/ Resample Tool

b/ Project Raster Tool (or ReProject function) EDIT: While this accepts a "Cell Size XY" Parameter, I notice that its help documentation states that it will only output square cells

c/ Split Raster Tool

d/ Rescale Tool

e/ ...?

 

Ways to store rasters with rectangular cells:

a/ As almost anything other than an Esri GRID

b/ In a Mosaic Dataset

 

Gotchas with processing rasters with rectangular cells:

a/ Spatial Analyst operations are based on square raster cells (see What happens with rectangular raster cells in Spatial Analyst? | ArcGIS Blog )

b/ Many other raster operations will resample to square raster cells - especially where they use the Cell Size Environment setting, which can only be set to a single value.

c/...?

Tags (1)
0 Kudos
7 Replies
larryzhang
Occasional Contributor III

Dave,

Hopefully, I get your points.

In remote sensing and photogrammetry (and computer graphics), the horizontal and vertical pixel spacing (x, y) is equal for most images, when recording/ acquiring images.

(Of course, in theory, it is not all true, in particular, in computer graphics).

Personally, it is not bug, because of the sensor design and computation simplicity…

However, when use ‘Resample’ tool, the output X and Y spacing can be managed:

import arcpy

arcpy.Resample_management("d:/data/airphoto.tif",
"resample.tif", "5 10", "
CUBIC")

0 Kudos
DavidMartin
Occasional Contributor II

Yes - I can see that square cells might lead to greater computational efficiency than would rectangular cells. Unfortunately, however, I'm stuck with having to output rectangular cells nevertheless!

Given that arcpy.NumPyArrayToRaster allows specification of a rectangular cell size, and can create such a raster in memory, I guess it still feels to me like a bug that when this raster is saved, its cell dimensions change.

0 Kudos
larryzhang
Occasional Contributor III

davd,

Trying to learn and then follow you.

On arcpy.NumPyArrayToRaster, nice to give a try via adjusting "y_cell_size= " from 2 to 10 and then see what is going to happen from the results of raster :

import arcpy
import numpy

# Create a simple array from scratch using random values
myArray = numpy.random.random_integers(2,100,2500)
myArray.shape = (50,50)

# Convert array to a geodatabase raster
myRaster = arcpy.NumPyArrayToRaster(myArray,x_cell_size=2, y_cell_size=10)
myRaster.save("D:/Default.gdb/myRandomRaster")

From the perspective on creating and manipulating "numerical data", it looks to me that here X cell size and Y cell size inside NumPyArrayToRaster is not equal to raster pixel size (base) that we are discussing.

Ceratinly, good idea to contact ESRI via the remedy for solid confirmation...

0 Kudos
DavidMartin
Occasional Contributor II

Thanks for looking at this, Larry.

I think, then, that your conclusion is the same as mine?? Certainly, running your code sample, and then investigating the properties of the resulting raster in Default.gdb (in 10.3), I see the cell size to be square (2, 2), and not rectangular (2,10).

0 Kudos
larryzhang
Occasional Contributor III

Yes,

+++++++++++++

However, Not sure if it is a bug, especially, when visualizing 2D arrays with "numerical data".

Personally, the different cell size (x, y) of 2D arrays (image) is currently not supported in FGDB and GRID format, because of computation complexity and very limited applications (?)

cell-size.JPG

0 Kudos
XanderBakker
Esri Esteemed Contributor

... for what purpose are you interested in using square cells?

0 Kudos
DavidMartin
Occasional Contributor II

I am seeking to meet a particular format specification which requires rectangular cells. It's not something I can therefore "work around" I'm afraid!

0 Kudos