程序崩溃,因为“#”被添加到某处的参数
Program crashing because '#' is being added to argument somewhere
我遇到了错误
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")
我知道代码乱得可笑,但我打算先得到它 运行。请随时发表评论以获取更多信息。
未在任何地方添加井号。那只是一个 ESRI 消息标志。
告诉你没有 shapefile \storage1\gis\temp\alpha.shp。请注意,它并没有告诉您 beta.shp 丢失了(尽管它也可能丢失)。
路径不正确。在行中的 table1 之后有一个额外的 'e':
pgsql2shp = 'pgsql2shp -f %s\table1e -h %s -p 5432 -P %s -u %s %s %s.%s' % (new_dir, host, password, username, db, schema1, table1)
然后,无论如何,您还是将文本 'table1' 放在那里,而不是 table 的名称。这是它的名字吗?
我猜你也想参数化它:
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)
在外围,您可以通过将 shapefile 名称分配给变量来清理整个事情:
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'
shp1 = os.path.join(new_dir, '{}.shp'.format(table1))
shp2 = os.path.join(new_dir, '{}.shp'.format(table2))
pgsql2shp = 'pgsql2shp -f %s -h %s -p 5432 -P %s -u %s %s %s.%s' % (shp1, host, password, username, db, schema1, table1)
subprocess.Popen(pgsql2shp, shell=True).wait()
pgsql2shp = 'pgsql2shp -f %s -h %s -p 5432 -P %s -u %s %s %s.%s' % (shp2, host, password, username, db, schema2, table2)
subprocess.Popen(pgsql2shp, shell=True).wait()
print('arguments:', shp1, shp2)
arcpy.Intersect_analysis([shp1, shp2], out_path, "ALL", 1.5)
arcpy.AddField_management(out_path, "intersect_area", "DOUBLE")
我遇到了错误
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")
我知道代码乱得可笑,但我打算先得到它 运行。请随时发表评论以获取更多信息。
未在任何地方添加井号。那只是一个 ESRI 消息标志。
告诉你没有 shapefile \storage1\gis\temp\alpha.shp。请注意,它并没有告诉您 beta.shp 丢失了(尽管它也可能丢失)。
路径不正确。在行中的 table1 之后有一个额外的 'e':
pgsql2shp = 'pgsql2shp -f %s\table1e -h %s -p 5432 -P %s -u %s %s %s.%s' % (new_dir, host, password, username, db, schema1, table1)
然后,无论如何,您还是将文本 'table1' 放在那里,而不是 table 的名称。这是它的名字吗?
我猜你也想参数化它:
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)
在外围,您可以通过将 shapefile 名称分配给变量来清理整个事情:
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'
shp1 = os.path.join(new_dir, '{}.shp'.format(table1))
shp2 = os.path.join(new_dir, '{}.shp'.format(table2))
pgsql2shp = 'pgsql2shp -f %s -h %s -p 5432 -P %s -u %s %s %s.%s' % (shp1, host, password, username, db, schema1, table1)
subprocess.Popen(pgsql2shp, shell=True).wait()
pgsql2shp = 'pgsql2shp -f %s -h %s -p 5432 -P %s -u %s %s %s.%s' % (shp2, host, password, username, db, schema2, table2)
subprocess.Popen(pgsql2shp, shell=True).wait()
print('arguments:', shp1, shp2)
arcpy.Intersect_analysis([shp1, shp2], out_path, "ALL", 1.5)
arcpy.AddField_management(out_path, "intersect_area", "DOUBLE")