有没有办法使用RasterFrames (http://rasterframes.io/)从tif文件中提取/查询纬度、经度和高程数据?
根据文档,我从以下网站loadRF了一个tif文件:https://visibleearth.nasa.gov/view.php?id=73934,但是我看到的都是通用信息,不知道使用哪个RasterFunction来提取位置和高程或任何其他相关信息。我确实尝试了我能在API中找到的所有东西。
我还尝试使用以下来源提取温度信息:http://worldclim.org/version2
我得到的只是带有扩展和边界( DoubleUserDefinedNoDataArrayTile或crs)的平铺列。
R中的RasterStack可以根据这个博客提取以下信息:https://www.benjaminbell.co.uk/2018/01/extracting-data-and-making-climate-maps.html
我需要一个更细粒度的DataFrame,比如lat、lon、temperature(或任何嵌入到tif文件中的数据)。
使用RasterFrames或GeoTrellis可以做到这一点吗?
发布于 2019-08-02 21:04:51
长话短说--是的,这是可能的(至少有了GeoTrellis)。我想,使用RasterFrames也是可能的,但需要一些时间来弄清楚如何提取这些数据。我不能回答更详细的问题,因为我需要了解更多关于数据集和您想要执行和应用的管道的信息。
发布于 2021-01-07 04:12:53
目前,您必须使用UDF和相关的GeoTrellis方法来完成此操作。
我们有一个票证可以作为一流的函数来实现,但同时,这是一个长形式:
import org.apache.spark.sql._
import org.apache.spark.sql.functions._
import org.locationtech.rasterframes._
import org.locationtech.rasterframes.datasource.raster._
import org.locationtech.rasterframes.encoders.CatalystSerializer._
import geotrellis.raster._
import geotrellis.vector.Extent
import org.locationtech.jts.geom.Point
object ValueAtPoint extends App {
implicit val spark = SparkSession.builder()
.master("local[*]").appName("RasterFrames")
.withKryoSerialization.getOrCreate().withRasterFrames
spark.sparkContext.setLogLevel("ERROR")
import spark.implicits._
val example = "https://raw.githubusercontent.com/locationtech/rasterframes/develop/core/src/test/resources/LC08_B7_Memphis_COG.tiff"
val rf = spark.read.raster.from(example).load()
val point = st_makePoint(766770.000, 3883995.000)
val rf_value_at_point = udf((extentEnc: Row, tile: Tile, point: Point) => {
val extent = extentEnc.to[Extent]
Raster(tile, extent).getDoubleValueAtPoint(point)
})
rf.where(st_intersects(rf_geometry($"proj_raster"), point))
.select(rf_value_at_point(rf_extent($"proj_raster"), rf_tile($"proj_raster"), point) as "value")
.show(false)
spark.stop()
}https://stackoverflow.com/questions/56913645
复制相似问题