I am quite new to ArcPy. However, I want to write a script that:

  • uses an existing SELECTED FEATURE of a feature class in a data frame of an existing MXD (on an SDE Server)
  • for a SELECT BY LOCATION operation of multiple existing feature classes
  • which in the next step are being COPIED to an existing local database for editing purposes
  • and CLIPPED within the boundaries of the selected feature (all the outside areas have to be clipped away)

Backgroud: I have access to a server database, on which I can't edit. Therefore I want to copy features of one FC (SDE) to another FC (local DB), but only the features which intersect the one selected feature in my MXD. Up to I only see that the feature layers contains the whole content of the FC (every feature), then ArcGIS needs around 30 minutes to create the feature layer, which then contains ALL features. The local_az FC does not have any information after the code finishes (without error message).

import arcpy

arcpy.env.workspace = r"C:\Users\KashlaBe\Desktop\Python"

sde_az = r"C:\Users\KashlaBe\Desktop\Python\db_sde.gdb\Aktenzeichenflaechen"
lokal_az = r"C:\Users\KashlaBe\Desktop\Python\db_lokal.gdb\lokal_az"

arcpy.env.overwriteOutput = True

arcpy.MakeFeatureLayer_management(sde_az, "betroffene_layer")

arcpy.SelectLayerByLocation_management("betroffene_layer", 'intersect', sde_az, '', 'NEW_SELECTION')

arcpy.Append_management("betroffene_layer", "lokal_az")
  • 2
    You have additional double quotation mark in '"intersect'. Remove the double qutation mark. 'intersect' – ahmadhanb Sep 27 '18 at 9:22
  • Thanks for the quick replies. The double quotation is removed. btw, when do I need the double quotes (") and when the single quotes ('). Here is the error message: C:\Python27\ArcGIS10.2\python.exe C:/Users/KashlaBe/PycharmProjects/firstproject/stackoverflow.py Traceback (most recent call last): ... raise e arcgisscripting.ExecuteError: Fehler bei Ausführung. Parameter sind ungültig. ERROR 000732: Eingabe-Features: Dataset sde_az ist nicht vorhanden oder wird nicht unterstützt. Fehler beim Ausführen von (MakeFeatureLayer). Process finished with exit code 1 – BeneBene Sep 27 '18 at 9:24
  • I have a browser based application which selects one feature in the FC sde_az within ArcGIS. What I want is to select (by location) all the other features within the FC sde_az (and later 20 more FCs). I created the "betroffene_layer" as a feature layer as I thought I need a feature layer to use the selection in the select by location step. – BeneBene Sep 27 '18 at 9:36
  • @BERA: Yes, the FC sde_az is the source for the input feature layer and the features that are to be selected. – BeneBene Sep 27 '18 at 9:48
  • 1
    I have edited my question, hopefully it helps understanding my problem... thanks! – BeneBene Sep 27 '18 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.