一.简介
1.基于hdfs进行shape文件的读取
- 实现local shapefile 到 hdfs shape文件的写入
- 实现hdfs shape 文件的读取
2.hdfs shape文件的写入时比较麻烦的
- 指定schema: schema 支持AttributeSchema,CompositeSchema,DateTimeSchema,FlatSchema,SpatialSchema,SZ2Schema,Z2Schema
- 指定encoding: encoding 支持convert,orc,parquet 三种格式,具体代码建 ParquetFileSystemStorage,其他俩个类似
二.代码
1.写入RDD到HDFS目录
//写入hdfs shape文件
def write_hdfs(inputRdd: SpatialRDD, hdfsHost: String, hdfsPath: String, hdfsFile: String)
(implicit sparkContext: SparkContext) = {
println("默认分区数:".concat(inputRdd.getNumPartitions.toString))
// val shpCount = inputRdd.count();
// var rddCount = shpCount / 2000;
// if (shpCount - rddCount * 2000 > 0) {
// rddCount = r