simple raster processing [python]

818
2
11-08-2010 03:04 AM
HugoAhlenius
Occasional Contributor
[python]
After importing arcpy.sa, I was a bit surprised at the behaviour with some simple processing...

I have set the cellSize and extent to be different from the original dataset, and if I then do:

newDataset = oldDataset


- then neither of these two properties change - it is just a copy of the original dataset.

But if I do:

newDataset = oldDataset+0


- then the new extent and cellsize are reflected


Is this expected behaviour? Coming from ArcInfo workstation/Grid I was expecting the first to work...
0 Kudos
2 Replies
NiklasNorrthon
Occasional Contributor III
Your first example is pure python, and is just creating a new name for the the object oldDataset.
The second example is performing a spatial analyst function and binding the result of that function to newDataset.

So yes, the behavior is expected. This is how python works, and has nothing to do with arcpy, or sa.

There are no variables in the python language, just names and objects. The assignment syntax binds an object to a name, it doesn't copy the underlying object.
0 Kudos
HugoAhlenius
Occasional Contributor
Yes, of course, my bad - I actually omitted one thing, the "strange" case is when I do:

newDataset = Raster("oldDataset")


That just assigns the dataset to that variable, when I expect a recalculation (according to the env settings)
0 Kudos