orlicha

Calculate distance from xy points to nearest raster cell of specific value

Discussion created by orlicha on Jan 10, 2014
Greetings~

I have a time series dataset of ~400 points from WGS84 overlaid onto 40 polar stereographic raster layers (1/day). I have since converted the xy into meters and have a code to extract the raster cell value to each point, linking them by date. Now I would like to find the distance from each point to the nearest raster cell value of <=15 for its respective date. So, using the same way to link the point to the raster by date, is there a tool or code to calculate the nearest cell of that value?

I'm thinking I can alter the GetCellValue command in the code below to grab the distance to the cell. I just can't find a tool for it.

Here's what I use to extract the raster cell value from the point(2009_Export_Output2):

import arcpy

featureClass = "C:\\Users\\me\\Desktop\\THESIS\\DATA\\ARC\\2009_Export_Output2"

rows = arcpy.SearchCursor("2009_Export_Output2")
cursor = arcpy.UpdateCursor("2009_Export_Output2")
row = rows.next()
crow = cursor.next()
counter = 0

from time import strptime, strftime
while row:
  timeStruct = strptime(row.Date, '%Y-%m-%d %H:%M:%S %Z')
  raster = strftime('AMSR_E_L3_SeaIce12km_V12_%Y%m%d_SI_12km_NH_ICECON_DAY.tif', timeStruct)
  print raster

  try:
    result = arcpy.GetCellValue_management(raster , str(row.LonMeter) + " " + str(row.LatMeter))
    output = result.getOutput(0)
    crow.AMSRE = output
    print output
    cursor.updateRow(crow)
  except:
    print "Catastrophe"

  counter += 1
  print counter
  crow = cursor.next()
  row = rows.next()

I hope this is easier than I'm making it out to be.

Thanks,
Alice

Outcomes