如何在 R 中将 shapefile 置于前面?

问题描述 投票:0回答:1

我想将名为“havza”的 shapefile 重叠到名为“gio_ara”的栅格数据上,但 shapefile 文件出现在图中栅格的后面,我该如何解决这个问题?

The black line at the back is the shapefile named

这是我的代码:

# Read Havza(region)
havza=readOGR(dsn= "D:\\FIRAT HAVZA", layer= "firat_havza_new")
plot(havza)

# Read Aralik PM DEM
gio_ara = readGDAL("D:\\FIRAT HAVZA\\Giovanni_PM10\\ara_pm")
gio_ara$RASTERVALU = gio_ara$band1
gio_ara$band1 = NULL
spplot(gio_ara, col.regions=bpy.colors(), scales=list(draw=T))

spplot(gio_ara, col.regions=bpy.colors(), main="Aralik PM10",scales=list(draw=T),
       sp.layout=list(havza))

我按照代码中写入的方式读取数据,但是shapefile数据总是出现在栅格数据后面。

我希望 shapefile 数据覆盖栅格。

提前致谢。

r overlay raster shapefile
1个回答
0
投票

这种方式可以帮助将形状文件覆盖在栅格上:

# Read Havza(region)
havza <- readOGR(dsn = "D:\\FIRAT HAVZA", layer = "firat_havza_new")

# Read Aralik PM DEM
gio_ara <- raster("D:\\FIRAT HAVZA\\Giovanni_PM10\\ara_pm")

# Plot the raster data
spplot(gio_ara, col.regions = bpy.colors(), scales = list(draw = TRUE))

# Plot the shapefile on top of the raster
plot(havza, add = TRUE)
© www.soinside.com 2019 - 2024. All rights reserved.