Subject: Marine Geospatial Ecology Tools (MGET) help
Text archives
From: | |
---|---|
To: | |
Subject: | [mget-help] Difficulty using ArcGISRaster.ToNumpyArray |
Date: | Fri, 14 May 2010 09:24:56 -0400 (EDT) |
Hi all,
I'm new to Python (and to coding in general), so I'm probably just being
thick,
but I'm having some trouble with MGET's ArcGISRaster.ToNumpyArray method.
My code executes successfully and the result appears to be a numpy.ndarray,
but
it doesn't behave like one. It doesn't have a shape, for example, and it
doesn't have the usual mathematical properties of an array. Instead, Python
seems to think that it's a 'tuple object', whatever that is. My simple test
code is as follows:
>>> import arcgisscripting
>>> import numpy as n
>>> from GeoEco.DataManagement.ArcGISRasters import ArcGISRaster
>>> gp = arcgisscripting.create(9.3)
>>> ras1 =
>>> ArcGISRaster.ToNumpyArray(r"D:\James_S\Map_Algebra_Test\os_10m_dtm")
>>> ras1
(array([[205, 205, 205, ..., 45, 45, 45],
[203, 204, 204, ..., 44, 44, 44],
[202, 202, 203, ..., 43, 43, 43],
...,
[230, 231, 232, ..., 68, 67, 66],
[230, 231, 232, ..., 68, 67, 66],
[231, 232, 233, ..., 67, 66, 65]], dtype=int16), -32768)
>>> ras1.shape
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'shape'
>>> ras1 + 1
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
TypeError: can only concatenate tuple (not "int") to tuple
>>> isinstance(ras1, n.ndarray)
False
What am I doing wrong? 'ras1' looks like an array to me, but Python doesn't
think so. Shouldn't the output from ArcGISRaster.ToNumpyArray have a shape,
and
shouldn't I be able to add 1 to each element by typing 'ras1 + 1'?
All feedback very much appreciated, and thanks for putting together such a
great set of tools!
Best wishes,
James.
I'm new to Python (and to coding in general), so I'm probably just being
thick,
but I'm having some trouble with MGET's ArcGISRaster.ToNumpyArray method.
My code executes successfully and the result appears to be a numpy.ndarray,
but
it doesn't behave like one. It doesn't have a shape, for example, and it
doesn't have the usual mathematical properties of an array. Instead, Python
seems to think that it's a 'tuple object', whatever that is. My simple test
code is as follows:
>>> import arcgisscripting
>>> import numpy as n
>>> from GeoEco.DataManagement.ArcGISRasters import ArcGISRaster
>>> gp = arcgisscripting.create(9.3)
>>> ras1 =
>>> ArcGISRaster.ToNumpyArray(r"D:\James_S\Map_Algebra_Test\os_10m_dtm")
>>> ras1
(array([[205, 205, 205, ..., 45, 45, 45],
[203, 204, 204, ..., 44, 44, 44],
[202, 202, 203, ..., 43, 43, 43],
...,
[230, 231, 232, ..., 68, 67, 66],
[230, 231, 232, ..., 68, 67, 66],
[231, 232, 233, ..., 67, 66, 65]], dtype=int16), -32768)
>>> ras1.shape
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'shape'
>>> ras1 + 1
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
TypeError: can only concatenate tuple (not "int") to tuple
>>> isinstance(ras1, n.ndarray)
False
What am I doing wrong? 'ras1' looks like an array to me, but Python doesn't
think so. Shouldn't the output from ArcGISRaster.ToNumpyArray have a shape,
and
shouldn't I be able to add 1 to each element by typing 'ras1 + 1'?
All feedback very much appreciated, and thanks for putting together such a
great set of tools!
Best wishes,
James.
Archives powered by MHonArc.