我有这个python脚本,它基本上通过它的ID选择一个点,然后选择一个距离内的所有点,并只返回与类型字段匹配的那些点的子集。即查找距离该地点3英里范围内的所有医院..
我的python脚本有效,做了它应该做的事情。所以我从中创建了一个GP服务。将服务添加回地图并运行它。现在我注意到无论我使用什么距离,数据都不会改变。如果我删除创建的Featureclass以查看它是否真的有效。它不会创建新的要素类,但它表示已成功完成。
现在是奇怪的部分,如果我在其余端点使用参数说它可以工作但没有返回任何记录的GP服务。使用Rest端点时,我一直小心避免模式锁定ArcMap和ArcCatalog已关闭。
就像GP服务没有权限写入sde数据库一样,但我的sde连接在我的电脑上工作正常。
有什么想法吗?
import arcpy, os, string
from arcpy import env
db = r"Connection to racdev1.sde"
theworkspace = r"Connection to racdev1.sde"
arcpy.env.workspace = theworkspace
arcpy.env.overwriteOutput = True
#facilityID = '1249'
facilityID = arcpy.GetParameterAsText(0)
#facilityIDType= 'PFI'
facilityIDType = arcpy.GetParameterAsText(1)
thedistance = arcpy.GetParameterAsText(2)
#thedistance = '3 miles'
#withindistance = "3 Miles"
withindistance = thedistance + ' Miles'
sql_query = "\"%s\" = '%s'" % ("ID", facilityID)
sql_query2 = "\"%s\" = '%s'" % ("IDTYPE", facilityIDType)
# Local variables:
Facilities = "DOHGIS.NYSDOH_CI_DATA"
featLayer = "thePts"
arcpy.MakeFeatureLayer_management(Facilities, featLayer)
# Process: Select Layer By Attribute
arcpy.SelectLayerByAttribute_management(featLayer, "NEW_SELECTION", sql_query)
# Process: Select Layer By Location 311
arcpy.SelectLayerByLocation_management(featLayer, "WITHIN_A_DISTANCE",featLayer, withindistance, "NEW_SELECTION")
#print " now for the subset"
arcpy.SelectLayerByAttribute_management("thePts", "SUBSET_SELECTION", sql_query2 )
# creaate the new featureclss..
arcpy.CopyFeatures_management("thePts",'DOHGIS.NYSDOH_FacilitiesQuery')
#print "Done"