AnsweredAssumed Answered

Arcpy Intersect_analysis - cannot use layers as input in a script

Question asked by kimo on May 5, 2015
Latest reply on May 5, 2015 by curtvprice

I prototyped a tool in ArcMap using a multiple intersect of a point featureclass with several polygon layers. Basically a multiple point-in-polygon operation.  It is much faster now that partitioning is automatically invoked at 10.3 (or some earlier version).


To avoid all the extra polygon fields I turn off all the additional fields in the layer properties. I do get extra FID_<fc> fields that I did not ask for but these are easy enough to delete with a list = [ for f in arcpy.Listfields(fc,'FID_*')] in the delete tool.


But now I want to put this in a script... I take the tool as a snippet and put it in a stand-alone script.  I need to define the layers, which I do using adding a Fieldinfo() object with all the fields hidden or visible. (the opposite of visible is..?)



the overlay produces a point layer BUT last polygon layer is repeated n times, the other (n-1) layers are missing, the process takes far too short a time and the result is nonsense, but with no error messages. I was hoping to use the rename facility in fieldinfo (it does not rename the alias so It needs an extra step) but since nothing works that was too much of a stretch. ie why got to the trouble of using fieldInfo anyway.


Intersect will properly populate FID_<fc_name> fields if I use the option 'ONLY_FID' on featureclasses, but then I have the tedious task of adding the fields and populating them myself. JoinField is not suitable for 2 million records. Maye MakeSQLQuery would be better if I had to go down that route, add indexes, build a complex sql expression. Oh, that won't work, because all the tables have to be in the same database, unlike spatialite.


The only workaround I can think of is to leave ALL the fields on with a list of featureclasses, not layers,  and then run a humongous delete function afterwards instead of a tidy fieldinfo beforehand.