最近用arcpy + 计算空间之后发布RESTful api, 使用 python27
有人遇到这事,按他的方法,改用
Flask app with ArcGIS, Arcpy does not run
https://stackoverflow.com/questions/51292905/flask-app-with-arcgis-arcpy-does-not-run
#coding:utf-8 import arcpy import time import random import sys from arcpy import env arcpy.env.workspace=ur'E:\yaxxnxxu\121xxx房xx\Data80.gdb' courtname = str(sys.argv[1]) surround_courts=[] fc_court = ur'RG\小区面' arcpy.MakeFeatureLayer_management(fc_court, 'court_lyr2') sql="Name='" + courtname +"'" arcpy.SelectLayerByAttribute_management('court_lyr2', "NEW_SELECTION", sql) temp = ''.join(random.sample('QWERTYUIOPASDFGHJKLZXCVBNMzyxwvutsrqponmlkjihgfedcba1234567890',10)) temp_buffer = "court_buffer" + temp temp_intersect = "court_intersect" + temp #每个幢缓冲是否在路边 200 米 arcpy.Buffer_analysis("court_lyr2", temp_buffer, "200 Meters") arcpy.SelectLayerByAttribute_management("court_lyr2", "CLEAR_SELECTION") arcpy.Intersect_analysis([temp_buffer,"court_lyr2"], temp_intersect,"ALL", "", "INPUT") ret = int(arcpy.GetCount_management(temp_intersect).getOutput(0)) if ret > 0: with arcpy.da.UpdateCursor(temp_intersect, ["Name_1"]) as cursor2: for row2 in cursor2: if row2!=courtname: surround_courts.append(row2[0]) del cursor2, row2 print surround_courts arcpy.Delete_management(temp_buffer) arcpy.Delete_management(temp_intersect)
#coding:utf-8 import time import sys import os sentence = (u'python2.exe D:\\code-arcpy\\xxx房xxx\\06dos.py 凤xxx小区') p = os.popen(sentence) courts = p.read() courts=courts.replace('[','').replace(']','').replace('\'','').replace('\n','') courts2=courts.split(',') for i in courts2: print i.decode('unicode_escape').strip().replace('u','')