我想知道这是否可以做到这一点 R 。
我有一个数据作为 SpatialLinesDataFrame,另一个作为 spatialPolygonDataFrame。是否可以叠加这两个数据?
当我尝试覆盖这些时,我收到以下错误:
jd <- overlay(res,hello)
Error in function (classes, fdef, mtable) : unable to find an inherited method for function
‘overlay’ for signature ‘"SpatialLinesDataFrame", "SpatialPolygonsDataFrame"’
在上面的代码中 res 是 SpatialLinesDataFrame 而 hello 是 SpatialPolygonDataFrame。
我有一个 shapefile,然后我有 x,yand z 坐标的数据点。我想在 shapefile 上显示等高线。
我使用的过程是使用 akima 包进行插值。我用来插值的代码是
fld <- interp(x,y,z)
然后我使用以下代码将其更改为空间对象:
res <-ContourLines2SLDF(contourLines(fld))
上述命令会将等高线存储为空间数据。
然后我阅读了 shapefile 并绘制了 shapefile 和 res 如下:
p1 <-
spplot(hello,sp.layout=list(list("sp.lines",res)),col="blue",lwd=0,fill="grey",colorkey=F)
p1
"hello" is my shapefile and "res" is the object I created as shown above.
The problem is contour stored in "res" extends beyond the shapefile. So I want to clip that contour with the shapefile and only display the contour within the shapefile area.
So I am looking for a way to clip the contour layer with the polygon layer.
I have attached the image I got with my code.
In the image you can see the lines out of the shapefile. I also want to know how can I display the contour levels on the map.
Thank you so much.
Jdbaba
I also want to know what does overlay does exactly. Does it intersect the area of both the data ?
Thank you.