Intersect with a specific feature and one unknown from gdb

1679
4
Jump to solution
03-17-2014 12:49 AM
DirkBrunken
New Contributor
Hello,

i want to find matching data from geodatabase. Thought at first, that arcpy.da.Walk is best way to get result, but maybe executing the tool Intersect is better.

Is it possible to set a feature and say, intersect with everything you find from gdb?

I am just a python beginner and want to shortly get results 😉
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Here is some code that you can work with.  What the code does is iterate through a feature class and searches all features in every feature class within the geodatabase to see if any features intersect (see the disjoint method here).  If features do, it adds the feature class name to a list.  I would recommend creating a single polygon from the input feature class's extent.  The code will then just have to iterate through one input feature rather than many.

import arcpy from arcpy import env env.workspace = r"C:\temp\python\test.gdb"  list = []  dataset = "Polygon" spatial_ref = arcpy.Describe(dataset).spatialReference  with arcpy.da.SearchCursor(dataset, ["SHAPE@"], "") as cursor:     for row in cursor:         for fc in arcpy.ListFeatureClasses("*"):             with arcpy.da.SearchCursor(fc, ["SHAPE@"], "", spatial_ref) as cursor2:                 for row2 in cursor2:                     if not row[0].disjoint(row2[0]):                         list.append(fc)  del cursor, cursor2  #remove duplicates from list list = dict.fromkeys(list) list = list.keys()  print list

View solution in original post

0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor
Hi Dirk,

Does this have to be accomplished using python?  It may be easiest to use Search in ArcMap.  You can add data to ArcMap that you would like to find which data intersects with it and specify an extent option:

[ATTACH=CONFIG]32229[/ATTACH]
0 Kudos
DirkBrunken
New Contributor
Hi Jake,

thanks for your answer. That option is indeed really helpful. It's maybe indeed more effort to build a script that automatically finds overlapping features/feature_classes. But in the other hand, i still want to know how that task could be solved 😄

Greets, Dirk
0 Kudos
DirkBrunken
New Contributor
and more specific asked..

how could i find data from a geodatabase that intersects with a single feature (e.g. a pointfeature).
Because, when i search for extent, its not that it is directly shown what really intersects or is ranked by percentage of intersection (what also would be nice to see and get)
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Here is some code that you can work with.  What the code does is iterate through a feature class and searches all features in every feature class within the geodatabase to see if any features intersect (see the disjoint method here).  If features do, it adds the feature class name to a list.  I would recommend creating a single polygon from the input feature class's extent.  The code will then just have to iterate through one input feature rather than many.

import arcpy from arcpy import env env.workspace = r"C:\temp\python\test.gdb"  list = []  dataset = "Polygon" spatial_ref = arcpy.Describe(dataset).spatialReference  with arcpy.da.SearchCursor(dataset, ["SHAPE@"], "") as cursor:     for row in cursor:         for fc in arcpy.ListFeatureClasses("*"):             with arcpy.da.SearchCursor(fc, ["SHAPE@"], "", spatial_ref) as cursor2:                 for row2 in cursor2:                     if not row[0].disjoint(row2[0]):                         list.append(fc)  del cursor, cursor2  #remove duplicates from list list = dict.fromkeys(list) list = list.keys()  print list
0 Kudos