Skip to main content
edited tags
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Using intersectIntersect with get parameter as textarcpy.GetParameterAsText() and ArcMap

I'm trying to use the intersect tool, with one of my inputs being from a get parameter as text. As I don't have an advanced licence I have to iterate through the list to run the intersect on each item in the list.

However, there is something about the input into the intersect analysis it doesnt like. I get the error message:

Traceback (most recent call last): File "\DRBS-NAS01\ueec\GIS\100 MT testing\BufferTest\Scripts\Intersection batch.py", line 37, in arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\test2", "ALL") File "c:\program files (x86)\arcgis\desktop10.7\arcpy\arcpy\analysis.py", line 334, in Intersect raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset SOBLayer #;'\DRBS-NAS01\ueec\GIS\100 MT testing\BufferTest\Data\Designations\Ancient_Woodland_England.shp' # does not exist or is not supported Failed to execute (Intersect).

Traceback (most recent call last): File "\DRBS-NAS01\ueec\GIS\100 MT testing\BufferTest\Scripts\Intersection batch.py", line 37, in arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\test2", "ALL") File "c:\program files (x86)\arcgis\desktop10.7\arcpy\arcpy\analysis.py", line 334, in Intersect raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset SOBLayer #;'\DRBS-NAS01\ueec\GIS\100 MT testing\BufferTest\Data\Designations\Ancient_Woodland_England.shp' # does not exist or is not supported Failed to execute (Intersect).

    import arcpy
    import os
    
    ## Working folders
    WorkingDir = os.getcwd()    ## To go up more directories: os.getcwd() 
    os.path.dirname(os.getcwd());  os.chdir(os.path.dirname(os.getcwd()))
    DesDir = WorkingDir + "\\Data\\Designations"
    OutputDir = WorkingDir + "\\Data\\Outputs"
    Interim = OutputDir + "\\Interim"
    DirectAndIndirect = OutputDir + "\\DirectAndIndirect"
    
    if not os.path.exists(DirectAndIndirect):
        os.makedirs(DirectAndIndirect)
    
    SiteOptions = arcpy.GetParameterAsText(0)
    SiteOptionsBuffers = arcpy.GetParameterAsText(1)
    
    DesList1 = arcpy.GetParameterAsText(2)
    DesList2 = DesList1.split(';')
    
    DesBufferList = arcpy.GetParameterAsText(3)
    
    arcpy.MakeFeatureLayer_management(SiteOptionsBuffers, "SOBLayer")
    
    query = '"IndImpBuff" = {}'.format(DesBufferList)
    arcpy.SelectLayerByAttribute_management("SOBLayer","NEW_SELECTION", query)
    
    Des4 = ["SOBLayer"]
    for Des1 in DesList2:
        Des2 = os.path.basename(Des1)
        Des4.append(Des1)
        arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\\test2", "ALL")

Could someone suggest what the problem with the Intersect input is please?

Using intersect with get parameter as text

I'm trying to use the intersect tool, with one of my inputs being from a get parameter as text. As I don't have an advanced licence I have to iterate through the list to run the intersect on each item in the list.

However, there is something about the input into the intersect analysis it doesnt like. I get the error message:

Traceback (most recent call last): File "\DRBS-NAS01\ueec\GIS\100 MT testing\BufferTest\Scripts\Intersection batch.py", line 37, in arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\test2", "ALL") File "c:\program files (x86)\arcgis\desktop10.7\arcpy\arcpy\analysis.py", line 334, in Intersect raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset SOBLayer #;'\DRBS-NAS01\ueec\GIS\100 MT testing\BufferTest\Data\Designations\Ancient_Woodland_England.shp' # does not exist or is not supported Failed to execute (Intersect).

    import arcpy
    import os
    
    ## Working folders
    WorkingDir = os.getcwd()    ## To go up more directories: os.getcwd() 
    os.path.dirname(os.getcwd());  os.chdir(os.path.dirname(os.getcwd()))
    DesDir = WorkingDir + "\\Data\\Designations"
    OutputDir = WorkingDir + "\\Data\\Outputs"
    Interim = OutputDir + "\\Interim"
    DirectAndIndirect = OutputDir + "\\DirectAndIndirect"
    
    if not os.path.exists(DirectAndIndirect):
        os.makedirs(DirectAndIndirect)
    
    SiteOptions = arcpy.GetParameterAsText(0)
    SiteOptionsBuffers = arcpy.GetParameterAsText(1)
    
    DesList1 = arcpy.GetParameterAsText(2)
    DesList2 = DesList1.split(';')
    
    DesBufferList = arcpy.GetParameterAsText(3)
    
    arcpy.MakeFeatureLayer_management(SiteOptionsBuffers, "SOBLayer")
    
    query = '"IndImpBuff" = {}'.format(DesBufferList)
    arcpy.SelectLayerByAttribute_management("SOBLayer","NEW_SELECTION", query)
    
    Des4 = ["SOBLayer"]
    for Des1 in DesList2:
        Des2 = os.path.basename(Des1)
        Des4.append(Des1)
        arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\\test2", "ALL")

Could someone suggest what the problem with the Intersect input is please?

Using Intersect with arcpy.GetParameterAsText() and ArcMap

I'm trying to use the intersect tool, with one of my inputs being from a get parameter as text. As I don't have an advanced licence I have to iterate through the list to run the intersect on each item in the list.

However, there is something about the input into the intersect analysis it doesnt like. I get the error message:

Traceback (most recent call last): File "\DRBS-NAS01\ueec\GIS\100 MT testing\BufferTest\Scripts\Intersection batch.py", line 37, in arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\test2", "ALL") File "c:\program files (x86)\arcgis\desktop10.7\arcpy\arcpy\analysis.py", line 334, in Intersect raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset SOBLayer #;'\DRBS-NAS01\ueec\GIS\100 MT testing\BufferTest\Data\Designations\Ancient_Woodland_England.shp' # does not exist or is not supported Failed to execute (Intersect).

    import arcpy
    import os
    
    ## Working folders
    WorkingDir = os.getcwd()    ## To go up more directories: os.getcwd() 
    os.path.dirname(os.getcwd());  os.chdir(os.path.dirname(os.getcwd()))
    DesDir = WorkingDir + "\\Data\\Designations"
    OutputDir = WorkingDir + "\\Data\\Outputs"
    Interim = OutputDir + "\\Interim"
    DirectAndIndirect = OutputDir + "\\DirectAndIndirect"
    
    if not os.path.exists(DirectAndIndirect):
        os.makedirs(DirectAndIndirect)
    
    SiteOptions = arcpy.GetParameterAsText(0)
    SiteOptionsBuffers = arcpy.GetParameterAsText(1)
    
    DesList1 = arcpy.GetParameterAsText(2)
    DesList2 = DesList1.split(';')
    
    DesBufferList = arcpy.GetParameterAsText(3)
    
    arcpy.MakeFeatureLayer_management(SiteOptionsBuffers, "SOBLayer")
    
    query = '"IndImpBuff" = {}'.format(DesBufferList)
    arcpy.SelectLayerByAttribute_management("SOBLayer","NEW_SELECTION", query)
    
    Des4 = ["SOBLayer"]
    for Des1 in DesList2:
        Des2 = os.path.basename(Des1)
        Des4.append(Des1)
        arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\\test2", "ALL")

Could someone suggest what the problem with the Intersect input is please?

import arcpy
import os

## Working folders
WorkingDir = os.getcwd()    ## To go up more directories: os.getcwd() 
os.path.dirname(os.getcwd());  os.chdir(os.path.dirname(os.getcwd()))
DesDir = WorkingDir + "\\Data\\Designations"
OutputDir = WorkingDir + "\\Data\\Outputs"
Interim = OutputDir + "\\Interim"
DirectAndIndirect = OutputDir + "\\DirectAndIndirect"

if not os.path.exists(DirectAndIndirect):
    os.makedirs(DirectAndIndirect)

SiteOptions = arcpy.GetParameterAsText(0)
SiteOptionsBuffers = arcpy.GetParameterAsText(1)

DesList1 = arcpy.GetParameterAsText(2)
DesList2 = DesList1.split(';')

DesBufferList = arcpy.GetParameterAsText(3)

arcpy.MakeFeatureLayer_management(SiteOptionsBuffers, "SOBLayer")

query = '"IndImpBuff" = {}'.format(DesBufferList)
arcpy.SelectLayerByAttribute_management("SOBLayer","NEW_SELECTION", query)

Des4 = ["SOBLayer"]
for Des1 in DesList2:
    Des2 = os.path.basename(Des1)
    Des4.append(Des1)
    arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\\test2", "ALL")
    import arcpy
    import os
    
    ## Working folders
    WorkingDir = os.getcwd()    ## To go up more directories: os.getcwd() 
    os.path.dirname(os.getcwd());  os.chdir(os.path.dirname(os.getcwd()))
    DesDir = WorkingDir + "\\Data\\Designations"
    OutputDir = WorkingDir + "\\Data\\Outputs"
    Interim = OutputDir + "\\Interim"
    DirectAndIndirect = OutputDir + "\\DirectAndIndirect"
    
    if not os.path.exists(DirectAndIndirect):
        os.makedirs(DirectAndIndirect)
    
    SiteOptions = arcpy.GetParameterAsText(0)
    SiteOptionsBuffers = arcpy.GetParameterAsText(1)
    
    DesList1 = arcpy.GetParameterAsText(2)
    DesList2 = DesList1.split(';')
    
    DesBufferList = arcpy.GetParameterAsText(3)
    
    arcpy.MakeFeatureLayer_management(SiteOptionsBuffers, "SOBLayer")
    
    query = '"IndImpBuff" = {}'.format(DesBufferList)
    arcpy.SelectLayerByAttribute_management("SOBLayer","NEW_SELECTION", query)
    
    Des4 = ["SOBLayer"]
    for Des1 in DesList2:
        Des2 = os.path.basename(Des1)
        Des4.append(Des1)
        arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\\test2", "ALL")
import arcpy
import os

## Working folders
WorkingDir = os.getcwd()    ## To go up more directories: os.getcwd() 
os.path.dirname(os.getcwd());  os.chdir(os.path.dirname(os.getcwd()))
DesDir = WorkingDir + "\\Data\\Designations"
OutputDir = WorkingDir + "\\Data\\Outputs"
Interim = OutputDir + "\\Interim"
DirectAndIndirect = OutputDir + "\\DirectAndIndirect"

if not os.path.exists(DirectAndIndirect):
    os.makedirs(DirectAndIndirect)

SiteOptions = arcpy.GetParameterAsText(0)
SiteOptionsBuffers = arcpy.GetParameterAsText(1)

DesList1 = arcpy.GetParameterAsText(2)
DesList2 = DesList1.split(';')

DesBufferList = arcpy.GetParameterAsText(3)

arcpy.MakeFeatureLayer_management(SiteOptionsBuffers, "SOBLayer")

query = '"IndImpBuff" = {}'.format(DesBufferList)
arcpy.SelectLayerByAttribute_management("SOBLayer","NEW_SELECTION", query)

Des4 = ["SOBLayer"]
for Des1 in DesList2:
    Des2 = os.path.basename(Des1)
    Des4.append(Des1)
    arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\\test2", "ALL")
    import arcpy
    import os
    
    ## Working folders
    WorkingDir = os.getcwd()    ## To go up more directories: os.getcwd() 
    os.path.dirname(os.getcwd());  os.chdir(os.path.dirname(os.getcwd()))
    DesDir = WorkingDir + "\\Data\\Designations"
    OutputDir = WorkingDir + "\\Data\\Outputs"
    Interim = OutputDir + "\\Interim"
    DirectAndIndirect = OutputDir + "\\DirectAndIndirect"
    
    if not os.path.exists(DirectAndIndirect):
        os.makedirs(DirectAndIndirect)
    
    SiteOptions = arcpy.GetParameterAsText(0)
    SiteOptionsBuffers = arcpy.GetParameterAsText(1)
    
    DesList1 = arcpy.GetParameterAsText(2)
    DesList2 = DesList1.split(';')
    
    DesBufferList = arcpy.GetParameterAsText(3)
    
    arcpy.MakeFeatureLayer_management(SiteOptionsBuffers, "SOBLayer")
    
    query = '"IndImpBuff" = {}'.format(DesBufferList)
    arcpy.SelectLayerByAttribute_management("SOBLayer","NEW_SELECTION", query)
    
    Des4 = ["SOBLayer"]
    for Des1 in DesList2:
        Des2 = os.path.basename(Des1)
        Des4.append(Des1)
        arcpy.Intersect_analysis(Des4, DirectAndIndirect + "\\test2", "ALL")
Source Link
Loading