ArcGIS 将工作空间中的栅格数据加载到地图中
利用arcpy将某工作空间下的栅格数据导入地图显示,代码如下
aprx = arcpy.mp.ArcGISProject("CURRENT")
map = aprx.activeMap
arcpy.env.workspace = "...工作空间"
for raster in arcpy.ListRasters():
layer = map.addDataFromPath(os.path.join(arcpy.env.workspace, raster))
想将栅格数据加入要当前地图指定图层组中,代码如下
aprx = arcpy.mp.ArcGISProject("CURRENT")
map = aprx.activeMap
for lyr in map.listLayers():
if lyr.name == '新建图层组'
group = lyr
break
arcpy.env.workspace = "...工作空间"
for raster in arcpy.ListRasters():
layer = map.addDataFromPath(os.path.join(arcpy.env.workspace, raster))
map.addLayerToGroup(group, layer)
map.removeLayer(layer)