Skip to Content.

mget-help - RE: [mget-help] Sample Time Series Code

Please Wait...

Subject: Marine Geospatial Ecology Tools (MGET) help

Text archives


From: "Jason Roberts" <>
To: "'Karl Zimmer'" <>
Cc: <>
Subject: RE: [mget-help] Sample Time Series Code
Date: Mon, 7 Jun 2010 16:12:28 -0400

Hi Karl,

 

We’re glad you find MGET helpful for your Pronghorn project. It is always nice to get positive feedback and hear how others are applying the software.

 

Unfortunately I doubt that it would be easy to morph the Sample Rasters Listed in Table tool’s Python code into the scenario you are looking for. MGET’s Python code is much more complicated than the examples you see in ArcGIS because much of it is split among a collection of modules that are then reused by many different tools in MGET. Also, it is designed to perform a lot of validation and handle a variety of situations that the ArcGIS examples do not even mention, resulting in a lot of code that is not directly related to the main purpose of a given tool of interest. It would be hard to go through this code and isolate the key parts that you would want. But if you want to take a look anyway, open the file C:\Python25\lib\site-packages\GeoEco\SpatialAnalysis\Sampling.py in your Python editor and look for “SampleRastersInFields” and you’ll see the function.

 

Rather than trying to copy that code, I suggest two alternatives:

 

1.    Write your own Python code from scratch. It shouldn’t be too complicated. You’ll need a SearchCursor to read rows from the polygon feature class. You can write a loop that goes through each polygon, reads the field that identifies the raster, makes a feature layer that selects just the polygon, and calls Zonal Statistics.

 

2.    Use ModelBuilder’s batch processing capability. You’ll have to read how to do this in the Arc docs. I’m not sure it will be easy to use a table as input to control the processing, but as an alternative, you could use the “batch grid” user interface to manually enter the data controlling it.

 

Good luck,

 

Jason

 

From: Karl Zimmer [mailto:]
Sent: Monday, June 07, 2010 3:47 PM
To:
Subject: [mget-help] Sample Time Series Code

 

Hello,


First off, I want to commend you on the great suite of tools you have developed with the MGET toolbox! They are all very helpful tools.  In particular, I have been finding your tool for sampling time series rasters very useful for some of my graduate work modelling Pronghorn antelope habitat. In any case, I want to do something a bit different, but in a similar process. Specifically, I want to calculate zonal statistics for a polygon feature class based on a raster listed in field in the table. So basically I want to do the same thing you describe in this example http://code.nicholas.duke.edu/projects/mget/wiki/Sampling%20time%20series%20rasters except instead of point data I want to use polygon data and instead of extracting raster values I want to get zonal statistics for the raster values in the field.  Therefore I was wondering if you could provide a sample of your code for your sampling time series data that I could modify for sampling polygons by zonal statistics. Or if you have any other advice or suggestions I would greatly appreciate it as I only have recently got into programming for ArcGIS so my skills are a little limited. 

 

Thanks for your time.

 

Cheers,

 

Karl Zimmer 
 

Karl Zimmer, B.Sc., MGIS (candidate), P.Biol.

Univeristy of Calgary,

Calgary, Alberta

 

Archives powered by MHonArc.
Top of Page