[Numpy-discussion] Crosstabulation

Ionut Sandric sandricionut@yahoo....
Mon Jul 19 13:39:11 CDT 2010


Thank you Vincent:

I will try with histogram

Ionut

----- Original Message -----
From: "Vincent Schut" <schut@sarvision.nl>
To: numpy-discussion@scipy.org
Sent: Monday, July 19, 2010 12:00:38 PM GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re: [Numpy-discussion] Crosstabulation



On 07/19/2010 09:55 AM, sandric ionut wrote:
>
> Hi Friedrich:
>
> For land-use a class would be for example forest, other would be orchard
> etc. For Slope gradient I would have values which <3 and between 3 and 7
> etc. So, I will have 2 raster data with, let's say, 3 classes each:
> forest, orchards and built-up area and for slope gradient: 0-3, 3-15,
> 15-35. The cross-tabulation analysis should give me a table like:
>
> forest orchards built-up
> 0-3 10 &n bsp; 20 15
> 3-15 5 10 20
> 15-35 5 15 15
>
> where the numbers represents all the common cells, for example: 10 cells
> with forest correspond to 10 cells with 0-3 slope gradient interval and
> so on
> (by cells I mean the pixel from a raster data)
>
> The analysis is better illustrated here:
> http://webhelp.esri.com/arcgisdesktop/9.2/index.cfm?TopicName=tabulate_area
>
> Ionut

Ha, we're messing up lingo's here :-) Need to switch to GIS (geographic 
information systems) dialect.
- DEM = digital elevation map, usually a 2d array ('raster') with 
elevation values (for a certain area on earth)
- slope gradient = the slope (literally, not as in math speak) of the 
surface depicted by the elevation map. Mostly defined as the maximum 
slope within a certain moving window; several competing methods to 
estimate/calculate slope exist.
- land use/cover class: raster (array) where each cell ('pixel') has an 
integer value, which maps to some well defined land use at that location 
(e.g. 0 means sea, 1 means forest, 2 means agriculture, etc)
- crosstabulation usually means some kind of 2d histogram, where the 
total number of raster cells with a certain value (e.g. depicting 'land 
use class') 'within' a range of values of another raster with the same 
shape (and matching locations). Like: how many cells of forest lie 
withing a slope range of 0-10 degrees?

Right. On to the answers. I think you should look into 
numpy.histogram2d, where you can do exactly what you want. Your land use 
array is x, your slope gradient array = y, then you define the bins as 
your class numbers (for x) and your slope gradient ranges (for y), and 
you will get a pixel count for each bin combination.

see: 
http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html

Regards,
Vincent Schut.

>
> ------------------------------------------------------------------------
> *From:* Friedrich Romstedt <friedrichromstedt@gmail.com>
> *To:* Discussion of Numerical Python <numpy-discussion@scipy.org>
> *Sent:* Sun, July 18, 2010 12:09:04 AM
> *Subject:* Re: [Numpy-discussion] Crosstabulation
>
> 2010/7/17 Robert Kern <robert.kern@gmail.com
> <mailto:robert.kern@gmail.com>>:
>  > On Sat, Jul 17, 2010 at 13:11, Friedrich Romstedt
>  > <friedrichromstedt@gmail.com <mailto:friedrichromstedt@gmail.com>> wrote:
>  >> 2010/7/14 Ionut Sandric <sandricionut@yahoo.com
> <mailto:sandricionut@yahoo.com>>:
>  >> I'm afraid also Zach does not understand what you are talking about
>  >> ... So my first question (please bear with me) would be: What's a dem?
>  >
>  > Digital Elevation Map.
>  >
>  >> (n/a in my dictionary) And sorry for the cross-talk on the other
>  >> first post by you ...
>  >>
>  >> And by slope gradient you mean second derivative?
>  >
>  > No, the first derivative. "Slope gradient" is a reasonably common,
>  > albeit somewhat redundant, idiom meaning the gradient of an elevation
>  > map.
>
> Thanks Robert, that clarifies a lot.
>
> But still I don't understand how the crosstabulation shall work. What
> are the "classes"?
>
> Friedrich
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org <mailto:NumPy-Discussion@scipy.org>
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion



      


More information about the NumPy-Discussion mailing list