/
HadoopSparkContextMethods.scala
131 lines (105 loc) · 5.46 KB
/
HadoopSparkContextMethods.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* Copyright 2016 Azavea
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package geotrellis.spark.io.hadoop
import geotrellis.proj4.CRS
import geotrellis.raster._
import geotrellis.tiling.TemporalProjectedExtent
import geotrellis.spark.io.hadoop.formats._
import geotrellis.vector._
import org.apache.spark._
import org.apache.spark.rdd._
import org.apache.hadoop.fs.Path
import org.apache.hadoop.mapreduce.Job
import org.apache.hadoop.conf.Configuration
trait HadoopSparkContextMethods {
implicit val sc: SparkContext
def hadoopGeoTiffRDD(path: String): RDD[(ProjectedExtent, Tile)] =
hadoopGeoTiffRDD(new Path(path), HadoopGeoTiffRDD.Options.DEFAULT.tiffExtensions)
def hadoopGeoTiffRDD(path: String, tiffExtension: String): RDD[(ProjectedExtent, Tile)] =
hadoopGeoTiffRDD(new Path(path), Seq(tiffExtension))
def hadoopGeoTiffRDD(path: String, tiffExtensions: Seq[String]): RDD[(ProjectedExtent, Tile)] =
hadoopGeoTiffRDD(new Path(path), tiffExtensions)
def hadoopGeoTiffRDD(path: Path): RDD[(ProjectedExtent, Tile)] =
hadoopGeoTiffRDD(path, HadoopGeoTiffRDD.Options.DEFAULT.tiffExtensions)
def hadoopGeoTiffRDD(path: Path, tiffExtension: String): RDD[(ProjectedExtent, Tile)] =
hadoopGeoTiffRDD(path, Seq(tiffExtension))
def hadoopGeoTiffRDD(path: Path, tiffExtensions: Seq[String], crs: Option[CRS] = None): RDD[(ProjectedExtent, Tile)] =
HadoopGeoTiffRDD.spatial(path, HadoopGeoTiffRDD.Options(
tiffExtensions = tiffExtensions,
crs = crs
))
def hadoopTemporalGeoTiffRDD(path: String): RDD[(TemporalProjectedExtent, Tile)] =
hadoopTemporalGeoTiffRDD(new Path(path), HadoopGeoTiffRDD.Options.DEFAULT.tiffExtensions)
def hadoopTemporalGeoTiffRDD(path: String, tiffExtension: String): RDD[(TemporalProjectedExtent, Tile)] =
hadoopTemporalGeoTiffRDD(new Path(path), Seq(tiffExtension))
def hadoopTemporalGeoTiffRDD(path: String, tiffExtensions: Seq[String] ): RDD[(TemporalProjectedExtent, Tile)] =
hadoopTemporalGeoTiffRDD(new Path(path), tiffExtensions)
def hadoopTemporalGeoTiffRDD(path: Path): RDD[(TemporalProjectedExtent, Tile)] =
hadoopTemporalGeoTiffRDD(path, HadoopGeoTiffRDD.Options.DEFAULT.tiffExtensions)
def hadoopTemporalGeoTiffRDD(path: Path, tiffExtension: String): RDD[(TemporalProjectedExtent, Tile)] =
hadoopTemporalGeoTiffRDD(path, Seq(tiffExtension))
def hadoopTemporalGeoTiffRDD(
path: Path,
tiffExtensions: Seq[String] = HadoopGeoTiffRDD.Options.DEFAULT.tiffExtensions,
timeTag: String = HadoopGeoTiffRDD.GEOTIFF_TIME_TAG_DEFAULT,
timeFormat: String = HadoopGeoTiffRDD.GEOTIFF_TIME_FORMAT_DEFAULT,
crs: Option[CRS] = None
): RDD[(TemporalProjectedExtent, Tile)] =
HadoopGeoTiffRDD.temporal(path, HadoopGeoTiffRDD.Options(
tiffExtensions = tiffExtensions,
timeTag = timeTag,
timeFormat = timeFormat,
crs = crs
))
def hadoopMultibandGeoTiffRDD(path: String): RDD[(ProjectedExtent, MultibandTile)] =
hadoopMultibandGeoTiffRDD(new Path(path), HadoopGeoTiffRDD.Options.DEFAULT.tiffExtensions)
def hadoopMultibandGeoTiffRDD(path: String, tiffExtension: String): RDD[(ProjectedExtent, MultibandTile)] =
hadoopMultibandGeoTiffRDD(new Path(path), Seq(tiffExtension))
def hadoopMultibandGeoTiffRDD(path: String, tiffExtensions: Seq[String]): RDD[(ProjectedExtent, MultibandTile)] =
hadoopMultibandGeoTiffRDD(new Path(path), tiffExtensions)
def hadoopMultibandGeoTiffRDD(
path: Path,
tiffExtensions: Seq[String] = HadoopGeoTiffRDD.Options.DEFAULT.tiffExtensions,
crs: Option[CRS] = None
): RDD[(ProjectedExtent, MultibandTile)] =
HadoopGeoTiffRDD.spatialMultiband(path, HadoopGeoTiffRDD.Options(
tiffExtensions = tiffExtensions,
crs = crs
))
def hadoopTemporalMultibandGeoTiffRDD(path: String): RDD[(TemporalProjectedExtent, MultibandTile)] =
hadoopTemporalMultibandGeoTiffRDD(new Path(path), HadoopGeoTiffRDD.Options.DEFAULT.tiffExtensions)
def hadoopTemporalMultibandGeoTiffRDD(path: String, tiffExtension: String): RDD[(TemporalProjectedExtent, MultibandTile)] =
hadoopTemporalMultibandGeoTiffRDD(new Path(path), Seq(tiffExtension))
def hadoopTemporalMultibandGeoTiffRDD(path: String, tiffExtensions: Seq[String]): RDD[(TemporalProjectedExtent, MultibandTile)] =
hadoopTemporalMultibandGeoTiffRDD(new Path(path), tiffExtensions)
def hadoopTemporalMultibandGeoTiffRDD(
path: Path,
tiffExtensions: Seq[String] = HadoopGeoTiffRDD.Options.DEFAULT.tiffExtensions,
timeTag: String = HadoopGeoTiffRDD.GEOTIFF_TIME_TAG_DEFAULT,
timeFormat: String = HadoopGeoTiffRDD.GEOTIFF_TIME_FORMAT_DEFAULT,
crs: Option[CRS] = None
): RDD[(TemporalProjectedExtent, MultibandTile)] =
HadoopGeoTiffRDD.temporalMultiband(path, HadoopGeoTiffRDD.Options(
tiffExtensions = tiffExtensions,
timeTag = timeTag,
timeFormat = timeFormat,
crs = crs
))
def newJob: Job =
Job.getInstance(sc.hadoopConfiguration)
def newJob(name: String) =
Job.getInstance(sc.hadoopConfiguration, name)
}