I am trying to write a Python script that will clip raster layers
using a vector polygon. The function call to do so looks like this:
gp.clip_management("gtopo_1km","-2.40438436932573 39.6271900031164
3.95492080927664
44.4723749010991","clip_test","spain.shp","-255","ClippingGeometry")
Is there a way to extract the bounding rectangle coordinates from the
clipping polygon from within the Python script? Having to specify
both the bounding rectangle coordinates and the clipping layer seems
redundant. I'm looking for a function that does this kind of thing:
maxX = getMax_X(spain.shp)
etc. This seems like it should be a simple thing to do. Does
anything like this exist for Python in ArcGIS 9.3?
Thanks. If I have missed something that is obvious, I will accept the
consequences.
|
|
0
|
|
|
|
Reply
|
richardlent (2)
|
2/23/2009 5:35:39 PM |
|
On 23 Feb, 18:35, Richard Lent <richardl...@gmail.com> wrote:
>
> Is there a way to extract the bounding rectangle coordinates from the
> clipping polygon from within the Python script? =A0
Lookup the Describe method of the geoprocessor:
>>> import arcgisscripting
>>> gp =3D arcgisscripting.create()
>>> gp.Describe('spain.shp').Extent
'356703.851202011 6161837.25290108 388919.895200729 6180982.37260246'
If you want the individual coordinates either use the 9.3 version of
creating the geoprocessor (with all its consecvenses), or just split
the returned string:
>>> gp.Describe('spain.shp').Extent.split()
['356703.851202011', '6161837.25290108', '388919.895200729', '
6180982.37260246']
And finally if you want the coordinates as floats and not strings, use
map and float:
>>> map(float, gp.Describe('spain.shp').Extent.split())
[356703.851202011, 6161837.25290108, 388919.895200729,
6180982.37260246]
/Niklas Norrthon
|
|
0
|
|
|
|
Reply
|
Niklas
|
2/26/2009 9:35:48 PM
|
|