I’m searching for the value from the field “demA_demA” which has the lowest elevation by having the value 8 from the field “outTable_2″.
How can I do this in the following script.
import arcpy
import os
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
env.overwriteOutput = True
env.workspace = r"D:Julia_Tprojektaufgabe2testdatenC"
inASCII = r"D:Julia_Tprojektaufgabe2testdatenC2007040_cloud_free.asc"
outRaster = inASCII + "_out.img"
rasterType = "INTEGER"
# Process: ASCII in Raster
arcpy.ASCIIToRaster_conversion(inASCII, outRaster, rasterType)
# Process: Projektion definieren
arcpy.DefineProjection_management(outRaster,"GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHER OID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")
# Process: Sample
outTable = r"D:Julia_Tprojektaufgabe2ergebnisse3outTable.dbf"
Sample(outRaster, outRaster, outTable, "NEAREST")
#works
# Join the table
# Table view
arcpy.MakeTableView_management(r"D:Julia_Tprojektaufgabe2ergebnisseoutTable.dbf", "out_tview") #works
joinField = "Y"
joinTable = r"D:Julia_Tprojektaufgabe2ergebnisse3demA.dbf"
arcpy.AddJoin_management("out_tview", joinField, joinTable, joinField, "KEEP_ALL")
# Persist the layer on disk
arcpy.CopyRows_management("out_tview", r"D:Julia_Tprojektaufgabe2ergebnisse3joinTestC.dbf")
# Execute CreateFileGDB
arcpy.CreateFileGDB_management(r"D:Julia_Tprojektaufgabe2result", "test1.gdb") #works
outLocation = r"D:Julia_Tprojektaufgabe2resulttest.gdb"
# Execute TableToTable
arcpy.TableToTable_conversion(r"D:Julia_Tprojektaufgabe2ergebnisse3joinTestC.dbf", outLocation, "jointest1") #works
# search for the lowest elevation with the value 8
with arcpy.da.SearchCursor (r"D:Julia_Tprojektaufgabe2resulttest1.gdbjointest1", ["outTable_2", "demA_demA"], """""demA_demA" = min("demA_demA")AND "outTable_2" = 8""") as cursor:
for row in cursor:
print row [0], row [1]
Do I have to add the geodatabase because of an subquery? How should I write the subquery? I’m pretty new and working with ArcMap 10.2.1