Skip to content

Commit 2373c8b

Browse files
committed
Added utility for creating a GeoJSON structure for all the tile footprints in a RasterFrame.
Signed-off-by: Simeon H.K. Fitch <[email protected]>
1 parent 9cde03c commit 2373c8b

File tree

1 file changed

+18
-0
lines changed
  • core/src/main/scala/astraea/spark/rasterframes/util/debug

1 file changed

+18
-0
lines changed

core/src/main/scala/astraea/spark/rasterframes/util/debug/package.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
package astraea.spark.rasterframes.util
2222

2323
import astraea.spark.rasterframes._
24+
import geotrellis.proj4.LatLng
25+
import geotrellis.vector.{Feature, Geometry}
26+
import geotrellis.vector.io.json.JsonFeatureCollection
27+
import spray.json.JsValue
2428

2529
/**
2630
* Additional debugging routines. No guarantees these are or will remain stable.
@@ -34,5 +38,19 @@ package object debug {
3438
def describeFullSchema: String = {
3539
self.schema.prettyJson
3640
}
41+
42+
/** Renders all the extents in this RasterFrame as GeoJSON in EPSG:4326. This does a full
43+
* table scan and collects **all** the geometry into the driver, and then converts it into a
44+
* Spray JSON data structure. Not performant, and for debugging only. */
45+
def geoJsonExtents: JsValue = {
46+
import spray.json.DefaultJsonProtocol._
47+
48+
val features = self
49+
.select(BOUNDS_COLUMN, SPATIAL_KEY_COLUMN)
50+
.collect()
51+
.map{ case (p, s) Feature(Geometry(p).reproject(self.crs, LatLng), Map("col" -> s.col, "row" -> s.row)) }
52+
53+
JsonFeatureCollection(features).toJson
54+
}
3755
}
3856
}

0 commit comments

Comments
 (0)