我有以下清单:
grouped_shapefiles
在每个文件夹中有以下文件目录:(pst和dbound对)
[['C:\\Users\\user\\Desktop\\eff\\20194\\DBOUND\\DBOUND.shp',
'C:\\Users\\user\\Desktop\\eff\\20194\\PST\\PST.shp'],
['C:\\Users\\user\\Desktop\\eff\\20042\\DBOUND\\DBOUND.shp',
'C:\\Users\\user\\Desktop\\eff\\20042\\PST\\PST.shp'],
['C:\\Users\\user\\Desktop\\eff\\20161\\DBOUND\\DBOUND.shp',
'C:\\Users\\user\\Desktop\\eff\\20161\\PST\\PST.shp'],
['C:\\Users\\user\\Desktop\\eff\\20029\\DBOUND\\DBOUND.shp',
'C:\\Users\\user\\Desktop\\eff\\20029\\PST\\PST.shp'],
['C:\\Users\\user\\Desktop\\eff\\20008\\DBOUND\\DBOUND.shp',
'C:\\Users\\user\\Desktop\\eff\\20008\\PST\\PST.shp']]
我想做一个for循环,在列表包含的每个文件夹(20194,20042,20161
等…)的每个pst
和dbound
对的相应文件中执行这段代码
import geopandas as gpd
import pandas
#pst = gpd.read_file(r'C:\Users\user\Desktop\New folder1\PST')#this is not needed in the final because it takes the path by it self
#dbound = gpd.read_file(r'C:\Users\user\Desktop\New folder1\DBOUND')#same here
dbound.reset_index(inplace=True)
wdp = gpd.sjoin(pst, dbound, how="inner", op='within')#each dbound and pst from every folder
wdp['DEC_ID']=wdp['index']
我只想知道如何创建for循环,它将执行应该执行的文件中的代码。我试过for循环和使用括号中的位置,但没有达到应有的效果
不确定我是否正确理解了您的问题,您是否正在尝试成对地遍历列表中的项?如果是这样的话,那就很直截了当了:
根据我的理解编辑
相关问题 更多 >
编程相关推荐