AnsweredAssumed Answered

OutPut Multiples Feature Class

Question asked by juanma93_6 on Mar 14, 2018

Hi,  I have this script that intersect one shapefile with multiples features class then i configure the script to insert  as toolbox script, the problem is the Toolbox script just give return one polygon and i need to return the N feature class of the geodatabase, thank you so mucho

This is the script

import arcpy,os,sys
reload(sys)
sys.setdefaultencoding('utf8')
Predio_Expediente_Solicitud = arcpy.arcpy.GetParameterAsText(0)

arcpy.env.workspace= arcpy.arcpy.GetParameterAsText(1)
##arcpy.env.overwriteOutput= True
##Predio_Expediente_Solicitud = r"C:\ANT\ReservasCampesinas.shp"
##arcpy.env.workspace= r"C:\DatosVarios\Fuentes_Externas.gdb"

f = open(r'C:\DatosVarios\ResultadoCruce.txt',"a")
FeatureClass = arcpy.ListFeatureClasses()
#AGREGAR CAPAS Y ATRIBUTO A INTERSECTAR
Nombre_Datos = {
"COMUNIDAD_NEGRA":"NOMBRE",
"PARQUE_NACIONAL_NATURAL" : "NOMBRE"
}
#######################################
for fc in FeatureClass:
Desc = arcpy.Describe(fc)
CopiaFC = arcpy.CopyFeatures_management(fc, "in_memory"+os.sep+fc)
#AGREGAR CAMPOS Y REALIZAR LOS RESPECTIVOS CALCULOS
arcpy.AddField_management(CopiaFC, "AREA_INTERSECCION", "DOUBLE", "", "", "", "Área de Intersección", "NULLABLE", "NON_REQUIRED", "")
arcpy.CalculateField_management(CopiaFC, "AREA_INTERSECCION", "!shape.area@meters! ", "PYTHON_9.3", "")

inFeatures = [CopiaFC, Predio_Expediente_Solicitud]
intersectOutput = "Intersect_"+Desc.name
Intersect = arcpy.Intersect_analysis(inFeatures, "in_memory"+os.sep+intersectOutput)

arcpy.AddField_management(Intersect, "PORCENTAJE_INTERSECCION", "DOUBLE", "", "", "", "Porcentaje de Intersección", "NULLABLE", "NON_REQUIRED", "")
arcpy.CalculateField_management(Intersect, "PORCENTAJE_INTERSECCION", "round((!shape.area@meters!/!AREA_INTERSECCION!)*100,2)", "PYTHON_9.3", "")

arcpy.AddField_management(Intersect,"FECHA_CRUCE","DATE")
arcpy.CalculateField_management(Intersect,"FECHA_CRUCE","time.strftime('%d/%m/%Y')","PYTHON")

arcpy.AddField_management(Intersect,"FECHA_CRUCE","DATE")
arcpy.CalculateField_management(Intersect,"FECHA_CRUCE","time.strftime('%d/%m/%Y')","PYTHON")
######################################################################################################################
Datos = arcpy.SearchCursor(Intersect,fields="AREA_INTERSECCION;NOMBRE;PORCENTAJE_INTERSECCION;FECHA_CRUCE")
f.write("Capa: "+Desc.name+ "\n")
for Dato in Datos:
NombreSitio = Dato.getValue(Nombre_Datos[Desc.name])
## NombreSitio.encode('utf-8')
f.write("--->Sitio: "+NombreSitio.encode('utf-8')+", Area Interseccion: "+str(Dato.getValue("AREA_INTERSECCION")) +", Porcentaje Interseccion: "+str(Dato.getValue("PORCENTAJE_INTERSECCION"))+"% "+ " ,Fecha de Cruce: "+str(Dato.getValue("FECHA_CRUCE"))+ "\n")

OutPut = arcpy.SetParameterAsText(2, Intersect)

f.close();

print "FIN !!! "

----------------------------------------------------------------------------------------

And this is the parameters config in the Toolbox

 

 

PD: If i run the script in the python IDE in arcmap they return the n features clases of the intersect but if i run in toolbox they return just the last feature class, thank you so much.

Outcomes