r-UTM中的范围和lat-lon中的投影



我有一个有4层的光栅,我想将范围转换为lon/lat,以便进行提取,但点和光栅投影或范围不匹配。你能帮帮我吗?

pp.an
class      : RasterBrick 
dimensions : 530, 748, 396440, 4  (nrow, ncol, ncell, nlayers)
resolution : 1000, 1000  (x, y)
extent     : 133000, 881000, 225000, 755000  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
source     : memory
names      :       X01,       X02,       X03,       X04 
min values :  13.12333,  12.16333,  16.02000,  13.00667 
max values :  75.00333,  65.92000,  88.52333, 100.46333 
: 01, 02, 03, 04 
pshp
class       : SpatialPoints 
features    : 5 
extent      : 27.25892, 27.38349, 44.43456, 44.55279  (xmin, xmax, ymin, ymax)
crs         : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
pshp<- data.frame(Y =  c(44.548684, 44.533389, 44.537298, 44.4345597, 44.552794), X = c(27.258922,27.282476,27.347930,27.331980,27.383491))
coordinates(pshp) <- ~X+Y
proj4string(pshp)<- CRS("+init=epsg:4326")
pshp1 <- spTransform(pshp,projection(p.p))
crs(pshp) <-"+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"
projectRaster(pp.an, crs = projection(pshp))
ex <- extract(pp.an, pshp1)
  1. 要从具有不同crs的光栅中提取点的值,您应该变换点,而不是光栅(以避免精度损失(。

  2. 显示CCD_ 1的crs被设置为CCD_。考虑到你说这是UTM和133000, 881000, 225000, 755000的范围,这显然是错误的

所以首先你需要设置正确的crs

crs(pp.an) <- "+proj=utm +zone=??? +datum=WGS84"

然后变换点

pshp1 <- spTransform(pshp, projection(pp.an))

然后使用extract

e <- extract(pp.an, pshp1)

最新更新