How to intersect two geometry objects with 9.3 geoprocessor

581
6
06-16-2011 08:13 AM
JörgMohring
New Contributor
Dear colleagues,

I have two geometry objects o1 and o2 created from arrays (e.g. o1 = gp.CreateObject("geometry", "polygon", array1).

Now I would like to intersect them. However

gp.Intersect_analysis("o1;o2",output) does not work, neither does
gp.Intersect_analysis(o1 + ";" + o2,output) work, nor does
gp.Intersect_analysis(str(o1) + ";" + str(o2),output) work.

Can it be that it's simply not possible to intersect geometry objects since the intersect tool requires strings?

Thank you for any help!
Jörg Mohring
0 Kudos
6 Replies
ChrisSnyder
Regular Contributor III
I could be wrong, but I thought you could only use the geometry objects directly in v10 GP tools (not in v93).
0 Kudos
JörgMohring
New Contributor
One can use them in v93 but the use is quite limited it seems. Thank you!
0 Kudos
DanPatterson_Retired
MVP Emeritus
check to see how you are creating the object from the example in the 9.3.1 help files
http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?id=966&pid=951&topicname=Using_geometry_objects_...
0 Kudos
ChrisSnyder
Regular Contributor III
Well, live and learn. I guess that's why I look at these forum posts...

Contrary to my beliefs 5 minutes ago:
1) You can use geomety objects directly in v9.3 (thought that was new in v10)
2) You can pass a list objects (maybe tuples?) directly into the v93 gp tools, and apparently no longer have to use string parameters.

#snipit of ESRI example code
inGeom1 = gp.createobject("geometry", "polygon", ary)
inGeom2 = gp.createobject("geometry", "polygon", ary2)
inGeoms = [inGeom1, inGeom2]
outGeom = gp.createobject("geometry")
newOutGeom = gp.union_analysis(inGeoms, outGeom)


Good to know...
0 Kudos
ChrisSnyder
Regular Contributor III
Jörg, per your original post, how about:

gp.Intersect_analysis([o1,o2],output)
0 Kudos
ChrisSnyder
Regular Contributor III
2) You can pass a list objects (maybe tuples?) directly into the v93 gp tools


Looks like this statement (at least in v9.3.1) only applies to geometry objects - not on disk FCs, so I wasn't completely wrong...

For example:

inputList = [r"D:\csny490\test.gdb\townships", r"D:\csny490\test.gdb\regions"]
outputFC =  r"D:\csny490\test.gdb\output"
gp.intersect_analysis(inputList, outputFC)


errors out, but

inputList = [r"D:\csny490\test.gdb\townships", r"D:\csny490\test.gdb\regions"]
outputFC =  r"D:\csny490\test.gdb\output"
gp.intersect_analysis(";".join(inputList), outputFC)


works fine.
0 Kudos