Re: record pixel value with Python script

2014-01-11 Thread maxerickson
On Saturday, January 11, 2014 5:53:00 PM UTC-5, DPod wrote:

> 
> I'd like to write a Python script for ArcGIS 10.x (ArcPy or Python 2.6.5) 
> >that would record the pixel value for all pixels in a raster. Furthermore, 
> I'd >like to only record a given value once in the results. For example, if 
> there >are 23 values of 180 overall, only record one instance of that value.
> 
> The raster in question is 4-band (6017 x 7715 pixels) so the results would 
> >have to include values for all pixels in each band, recorded separately by 
> >band. Ideally I'd like to write to an Excel file or at least a .csv file.
> 

Can you install libraries?

Fetching the pixel values of an individual band is straightforward in PIL (and 
the fork Pillow), something like this:

from PIL import Image
im=Image.open("blah.jpg")
red=im.getdata(0)

If you can't install things you would need to figure out if ArcGIS has an API 
for fetching a band.

The filtering step is easy, you just want the set of values:

set(red)


Max



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Two Questions about Python on Windows

2014-04-03 Thread maxerickson
On Thursday, April 3, 2014 1:06:29 PM UTC-4, Walter Hurry wrote:
> Normally my Python development is done on FreeBSD and Linux. I know that on 
> *ix I simply have to make foo.py executable (the shebang line is present, of 
> course) to make it runnable.
> 
> For my son's school assignment, I have to help him with Python for Windows.
> 
> As I understand it, on Windows a .py file is not executable, so I need to run 
> 'python foo py', or use a .pyw file.
> 
> Question 1: Do I make a .pyw file simply by copying or renaming foo.py to 
> foo.pyw?
> 
> Secondly, on *ix, if there's an up-to-date .pyc in the right place and I run 
> foo.py, Python will automagically use foo.pyc.
>  
> Question 2: Does it work the same way on Windows, and does this apply both to 
> >foo.py and foo.pyw?

The compile caching is more or less the same. It works transparently.

If you are working in a cmd shell, it doesn't matter what extension you use, 
pyw just allows for associating scripts with an interpreter stub that does not 
bring up a shell (for a gui or whatever). Console and gui programs are handled 
separately on Windows and that's how Python makes the option available to 
scripts.

You can also edit the PATHEXT environment variable to include .py/.pyw, making 
the python source files executable (as long as the types are properly 
registered with Windows; if double clicking runs them they should be properly 
registered).


Max
-- 
https://mail.python.org/mailman/listinfo/python-list