如何使用R覆盖levelplot中的cernatin点值?

时间:2017-01-31 04:34:50

标签: r raster levelplot

我有光栅(DEM)

class       : RasterLayer 
dimensions  : 164, 96, 15744  (nrow, ncol, ncell)
resolution  : 0.0002777778, 0.0002777778  (x, y)
extent      : 83.47915, 83.50582, 28.80114, 28.84669  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
data source : in memory
names       : layer 
values      : -4.737531, 0.554273  (min, max)

我希望覆盖点值

p = -3.9837500 -2.6327150 -1.4857878 -1.0200000 -0.7716000

在以下lat-long

lat=28.80046, 28.80381, 28.81314, 28.81314, 28.81144
lon=83.49621, 83.49524, 83.49450, 83.49450, 83.49201

1 个答案:

答案 0 :(得分:1)

制作空间点数据框;

p = -3.9837500 -2.6327150 -1.4857878 -1.0200000 -0.7716000
lat=28.80046, 28.80381, 28.81314, 28.81314, 28.81144
lon=83.49621, 83.49524, 83.49450, 83.49450, 83.49201

df <- data.frame(lat = lat, lon= lon, z = p)
coordinates(df) <- ~lon+lat
crs(df) <- projection(yourRas)

使用&#39; sp.points&#39;

添加到rasterVis图
levelplot(yourRas) +
    layer(sp.points(df, size=3))