一. 简介
- 读取shapefile 单文件
- 读取shapefile 路径下的所有shapefile 文件
- 保持输出单shapefile 文件
- 保持输出shapefile 集合到指定文件路径
优化:
- 读取目录下说有shape为RDD
- 分区输出shapefiles时,先进行空间分区
二. 代码
1.本地Shapefile 文件读取
//读取shapefile
def read_shapefile(shapePath: String, shapeName: String)(implicit sparkContext: SparkContext) = {
var intpuParams: Map[String, String] = Map()
var File = new File(shapePath)
intpuParams += ("url" -> File.toURI.toURL.toString)
intpuParams += ("geotools" -> "true")
val query = new Query(shapeName)
val inputRdd = GeoMesaSpark(intpuParams).rdd(new Configuration(), sparkContext, intpuParams, query)
println(inputRdd.schema) //打印方案
inputRdd
}