Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val crs_coord_1 = ???
- val crs_coord_2 = ???
- // you first want to create a Raster
- // assuming your rdd is a single tile representing the whole image, i.e. rdd.count == 1
- val first = rdd.take(1)
- val projExtent = first(0)._1
- val tile = first(0)._2
- // rgwozdz: My rdd isn't a single tile. On ingest my layer is tiled
- // across zooms 0 - 6. Should I be reading a particular zoom level?
- // Since I have more than one tile, how should above be adjusted?
- val raster = Raster(tile, projExtent.extent)
- // rgwozdz: The line above fails, because projExtent is of type
- // SpatialKey and apparently field "extent" does not exist
- // Then, `Raster` will give you access to `RasterExtent`, which contains a function to convert crs coordinates to underlying grid (pixel) coordinates:
- val rasterExtent = raster.rasterExtent
- // Finally, you can get value at specific row/columns from your tile
- val (col, row) = rasterExtent.mapToGrid(crs_coord_1, crs_coord_2)
- val pixelValue = raster.tile.get(col, row)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement