Select to view content in your preferred language

Select by Location in stand alone script

1027
7
Jump to solution
12-07-2023 03:44 AM
SoratoSouza_e_Silva
Frequent Contributor

Hi,

I would like to create stand alone script for do the select by location using two features.

How can I do that?

Using the documentation the error below show:

ExecuteError: Failed to execute. Parameters are not valid.

ERROR 000368: Invalid input data.

Failed to execute (SelectLayerByLocation).

 

Thank´s

 

 

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RichardHowe
Frequent Contributor

Select by location operates on feature layers (i.e. objects in an ArcGIS Pro session table of contents). Not on feature classes, which is what you're currently feeding into your script.

If you add a "Make Feature Layer" operation uysing your inputs, then use the outputs of that for your select by location then you should get there.

View solution in original post

0 Kudos
7 Replies
DanPatterson
MVP Esteemed Contributor

Select Layer By Location (Data Management)—ArcGIS Pro | Documentation

which code sample are you following and what is your script code?


... sort of retired...
0 Kudos
SoratoSouza_e_Silva
Frequent Contributor

Follow below my code:

import arcpy

entrada = r"D:\\Profile\\OneDrive - Imagem Geosistemas e Comercio LTDA\\Documentos\\ArcGIS\\Projects\\MyProject10\\MyProject10.gdb\\teste"
recorte = r"D:\\Profile\\OneDrive - Imagem Geosistemas e Comercio LTDA\\Documentos\\ArcGIS\\Projects\\MyProject10\\MyProject10.gdb\\teste1"
saida = r"D:\\Profile\\OneDrive - Imagem Geosistemas e Comercio LTDA\\Documentos\\ArcGIS\\Projects\\MyProject10\\MyProject10.gdb\\teste_saida"


fst = arcpy.SelectLayerByLocation_management(entrada,'intersect', recorte)
arcpy.conversion.ExportFeatures(fst,saida)

 

No work unfortunately.

Thank´s

0 Kudos
DanPatterson
MVP Esteemed Contributor

Move your data to a local folder on your computer.  One Drive isn't supported


... sort of retired...
0 Kudos
SoratoSouza_e_Silva
Frequent Contributor

Yes, I understand! I was changed to local folder already, but no work. The same error shows.

RichardHowe
Frequent Contributor

Select by location operates on feature layers (i.e. objects in an ArcGIS Pro session table of contents). Not on feature classes, which is what you're currently feeding into your script.

If you add a "Make Feature Layer" operation uysing your inputs, then use the outputs of that for your select by location then you should get there.

0 Kudos
SoratoSouza_e_Silva
Frequent Contributor

Hi!

Solved my problem. Thanks.

RichardHowe
Frequent Contributor

Awesome. Can you mark it as an accepted solution then pls 🙂

0 Kudos