小编Nig*_*use的帖子

在R中创建一组长度递减的序列

我想制作一组从x到20的序列,x = c(2:19).基本上我想要这个,但不必这样做:

a = seq(2, 20)
b = seq(3, 20)
...
q = seq(18, 20)
r = seq(19, 20)

> a
 [1]  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
> b
 [1]  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
...
> q
[1] 18 19 20
> r
[1] 19 20`
Run Code Online (Sandbox Code Playgroud)

我尝试使用for循环,但我无法让替换工作:

a = c(2:20)
b …
Run Code Online (Sandbox Code Playgroud)

r sequence

3
推荐指数
1
解决办法
1525
查看次数

重新投影 SpatialPointsDataFrame 不会改变范围

我正在尝试将与蝙蝠位置 (SpatialPointsDataFrame) 相关的数据叠加到科罗拉多州 (SpatialPolygonsDataFrame) 上。两个对象的CRS不同:

crs(colorado)
#CRS arguments:
# +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
crs(BatRange_data)
#CRS arguments:
# +proj=utm +zone=13 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0 
Run Code Online (Sandbox Code Playgroud)

当我重新投影蝙蝠数据时,CRS确实发生了变化,但程度不受影响。

前:

BatRange_data
#class       : SpatialPointsDataFrame 
#features    : 2456 
#extent      : 139996.3, 748812, 4094998, 4535103  (xmin, xmax, ymin, ymax)
#coord. ref. : +proj=utm +zone=13 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0 
#variables   : 17
Run Code Online (Sandbox Code Playgroud)

后:

geo_proj = "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
crs(BatRange_data) = geo_proj

BatRange_trnsfrmd = spTransform(BatRange_data,geo_proj)
BatRange_trnsfrmd
#class       : SpatialPointsDataFrame 
#features    : 2456 
#extent      : …
Run Code Online (Sandbox Code Playgroud)

r rgdal r-raster r-sp

2
推荐指数
1
解决办法
2810
查看次数

标签 统计

r ×2

r-raster ×1

r-sp ×1

rgdal ×1

sequence ×1