-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
140 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
geop/src/main/scala/com/azavea/usace/programanalysis/geop/LayerReader.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.azavea.usace.programanalysis.geop | ||
|
||
import geotrellis.raster.Tile | ||
import geotrellis.spark.io._ | ||
import geotrellis.spark.{SpatialKey, LayerId} | ||
import geotrellis.spark.io.s3.{S3AttributeStore, S3ValueReader} | ||
|
||
import org.apache.spark.SparkContext | ||
|
||
object LayerReader { | ||
/** | ||
* Given values for zoom, x and y, and a spark context, returns | ||
* the corresponding [[Tile]] object. | ||
* | ||
* @param zoom [[Int]] value of zoom level | ||
* @param x [[Int]] x-value of the spatial key | ||
* @param y [[Int]] y-value of the spatial key | ||
* @param sc [[SparkContext]] for the [[S3ValueReader]] | ||
* @return [[Tile]] object | ||
*/ | ||
def apply( | ||
zoom: Int, | ||
x: Int, | ||
y: Int, | ||
sc: SparkContext | ||
): Tile = { | ||
val sKey = SpatialKey(x, y) | ||
val rdr = catalog(sc, zoom) | ||
|
||
rdr.read(sKey) | ||
} | ||
|
||
/** | ||
* Given a spark context, returns the correct catalog. This configures the | ||
* next method with defaults. | ||
* | ||
*/ | ||
def catalog(sc: SparkContext, zoom: Int): Reader[SpatialKey, Tile] = | ||
catalog("azavea-datahub", "catalog", zoom)(sc) | ||
|
||
def catalog( | ||
bucket: String, | ||
rootPath: String, | ||
zoom: Int | ||
)(implicit sc: SparkContext): Reader[SpatialKey, Tile] = { | ||
val attributeStore = new S3AttributeStore(bucket, rootPath) | ||
val vr = new S3ValueReader(attributeStore) | ||
val layer = LayerId("nlcd-zoomed", zoom) | ||
val reader: Reader[SpatialKey, Tile] = vr.reader(layer) | ||
|
||
reader | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters