python中求取余数用的是 % ,也就是百分号。a % b = c

向下取整:int(a)

def Cal(y):
  yIndex = (y-32.601709392)/0.000833
  zheng = int(yIndex)
  yu = yIndex - zheng
  return yIndex

改进后:

def Cal(y):
  yIndex = (y-32.601709392)/0.000833
  zheng = int(yIndex)
  yu = yIndex - zheng
  if(yu>0):
    return zheng+1;
  else:
    return zheng

 行号:Cal( !y! )     对应ascrow    Cal(!lttd!)

def Cal(x):
  xIndex = (x-102.5302245)/0.000833
  zheng = int(xIndex)
  yu = xIndex - zheng
  if(yu>0):
    return zheng+1;
  else:
    return zheng

列号:Cal( !x! )     对应asccol     Cal(!lgtd!)

  

arcgis的asc文件的y方向是从大到小。所以

 (y-32.601709392)  -->  (34.385995392-y),得到:

def Cal(y):
  yIndex = (34.385995392-y)/0.000833
  zheng = int(yIndex)
  yu = yIndex - zheng
  if(yu>0):
    return zheng+1;
  else:
    return zheng