如何使用范围信息获取栅格的像元号?

How can I get the cell number of a raster using extent information?

我有一个光栅,我正在使用光栅包。

class       : RasterLayer 
dimensions  : 103, 118, 12154  (nrow, ncol, ncell)
resolution  : 0.008333333, 0.008333333  (x, y)
extent      : -83.075, -82.09167, 34.95833, 35.81667  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
data source : C:\fb.tif 
names       : fdr_fb 
values      : 1, 128  (min, max)

我知道如何子集和所有。但是如何使用 Lat-Long 值找到 cellnumber(首选)或 cellvalue?

例如,我可以使用 lat/long:

查找单元格值
extract(ras,SpatialPoints(cbind(-82.8,35.2))) 

但我想找到对应于 (Say) Long= -82.1 和 Lat= 35.0

的单元格编号 (row,col)

光栅:https://www.dropbox.com/s/8nhfirxr2hm3l4v/fdr_fb.tif?dl=0

要从一个点获取单元格编号,您可以这样做:

cellFromXY(ras, cbind(-82.8, 35.2))

如果你有一个 Extent 对象 e 你可以这样做:

cellsFromExtent(ras, e)