Advertisement
Guest User

Untitled

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