Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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".

enter image description here

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_T\projekt\aufgabe2\testdatenC"

inASCII = r"D:\Julia_T\projekt\aufgabe2\testdatenC\2007040_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_T\projekt\aufgabe2\ergebnisse3\outTable.dbf"
Sample(outRaster, outRaster, outTable, "NEAREST")
#works
# Join the table
# Table view
arcpy.MakeTableView_management(r"D:\Julia_T\projekt\aufgabe2\ergebnisse\outTable.dbf",     "out_tview") #works

joinField = "Y"
joinTable = r"D:\Julia_T\projekt\aufgabe2\ergebnisse3\demA.dbf"
arcpy.AddJoin_management("out_tview", joinField, joinTable, joinField, "KEEP_ALL")
# Persist the layer on disk
arcpy.CopyRows_management("out_tview",     r"D:\Julia_T\projekt\aufgabe2\ergebnisse3\joinTestC.dbf")
# Execute CreateFileGDB
arcpy.CreateFileGDB_management(r"D:\Julia_T\projekt\aufgabe2\result", "test1.gdb")     #works
outLocation = r"D:\Julia_T\projekt\aufgabe2\result\test.gdb"
# Execute TableToTable
arcpy.TableToTable_conversion(r"D:\Julia_T\projekt\aufgabe2\ergebnisse3\joinTestC.dbf",     outLocation, "jointest1") #works
# search for the lowest elevation with the value 8
with arcpy.da.SearchCursor (r"D:\Julia_T\projekt\aufgabe2\result\test1.gdb\jointest1",     ["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

share|improve this question
    
I suspect that this question amounts to a (near) duplicate of gis.stackexchange.com/questions/70488/… but in any event as @Hornbydd says the way to achieve this is by using the Summary Statistics tool. –  PolyGeo Aug 4 at 9:20

1 Answer 1

up vote 3 down vote accepted

So using your screenshot for an example you are searching for the minimum value in demA-demA where outtable_2 = 8, so in this example it would 3356?

If this is correct then this is simply the summary statistics tool. Your CASE field would be outtable_2 and you are returning the minimum value from demA_demA

share|improve this answer
    
Perfect, that is much better than what I thought! Thanks a lot! –  Nora Aug 4 at 11:04
    
So I added this: `` arcpy.CopyRows_management("out_tview", r"D:\Julia_T\projekt\aufgabe2\testdE\ergebnisE\joinXYZB7.dbf") #works arcpy.Statistics_analysis (r"D:\Julia_T\projekt\aufgabe2\testdE\ergebnisE\joinXYZB7.dbf", "D:\Julia_T\projekt\aufgabe2\testdE\ergebnisE\statistic1.dbf", [["dem500_dem", "MIN"], ["outTable1_", "MAX"]], "outTable1_")`` But I get the ERORR 000210 and don't know way. –  Nora Aug 4 at 12:18
    
put an r in front of the path name for your output table like you have done for your input table. –  Hornbydd Aug 4 at 14:41
    
Thanks, it works also with a list and .appand. –  Nora Aug 5 at 13:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.