我收到了错误
Traceback (most recent call last):
arcpy.Intersect_analysis([new_dir+'\\'+table1+'.shp', new_dir+'\\'+table2+'.shp'], out_path, "ALL", 1.5)
File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\analysis.py", line 289, in Intersect
raise e
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset \\storage1\gis\temp\alpha.shp #;\\storage1\gistemp\beta.shp # does not exist or is not supported
Failed to execute (Intersect).
我无法弄清楚#的来源。这是相关代码
host = sys.argv[1]
db = sys.argv[2]
schema1 = sys.argv[3]
schema2 = sys.argv[4]
username = sys.argv[5]
password = sys.argv[6]
table1 = sys.argv[7]
table2 = sys.argv[8]
out_path = r'\\storage1\gis\temp\intersected.shp'
new_dir = r'\\storage1\gis\temp\'
pgsql2shp = 'pgsql2shp -f %s\\table1e -h %s -p 5432 -P %s -u %s %s %s.%s' % (new_dir, host, password, username, db, schema1, table1)
subprocess.Popen(pgsql2shp, shell=True).wait()
pgsql2shp = 'pgsql2shp -f %s\\table2 -h %s -p 5432 -P %s -u %s %s %s.%s' % (new_dir, host, password, username, db, schema2, table2)
subprocess.Popen(pgsql2shp, shell=True).wait()
print('argument:'+ new_dir+'\\'+table1+'.shp'+' , '+ new_dir+'\\'+table2+'.shp')
arcpy.Intersect_analysis([new_dir+'\\'+table1+'.shp', new_dir+'\\'+table2+'.shp'], out_path, "ALL", 1.5)
arcpy.AddField_management(out_path, "intersect_area", "DOUBLE")
我知道这些代码非常混乱,但我打算先让它运行。请随时发表评论以获取更多信息。
答案 0 :(得分:1)
在任何地方都没有添加英镑符号。这只是一个ESRI消息标志。
它告诉你没有shapefile \ storage1 \ gis \ temp \ alpha.shp。请注意,它没有告诉您beta.shp丢失(尽管可能也是如此)。
路径不正确。你有一个额外的' e'在行中的table1之后:
closeLink.onclick = function(){
liTag.remove();
}
然后,您再次放置文字' table1'无论如何,而不是表的名称。这是它的名字吗?
我猜你也想要参数化它:
pgsql2shp = 'pgsql2shp -f %s\\table1e -h %s -p 5432 -P %s -u %s %s %s.%s' % (new_dir, host, password, username, db, schema1, table1)
从外部来看,您可以通过将shapefile名称分配给变量来清理整个事物:
pgsql2shp = 'pgsql2shp -f %s\\%s -h %s -p 5432 -P %s -u %s %s %s.%s' % (new_dir, table1, host, password, username, db, schema1, table1)