val intersect = SpatialOperatorType.Intersect
//获取永久基本农田内的建设用地图斑
val polygonInRedLine = OverlayAnalyst.overlayIndexRDD(indexDLRDD, indexRedLineRDD, srcFields, overlayFields, intersect, 0.000001, isIniProcess = false)
println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
println("基础数据叠加分析后图斑数据量为===" + polygonInRedLine.count())
println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
val outParams = SaveData.savaInPostGis()
if (range.length > 6) {
val ranges = range.split("#")
//通过范围来构建RDD
val targetFields = Array.concat(srcFields, overlayFields)
val rangeRDD = CommonUtils.polygon2FeatureRDD2(sc, ranges: _*)
polygonInRedLine.withFeatureID(Array("objectid"))
if (!polygonInRedLine.hasFeatureID) {
sys.error("原FeatureRDD没有FeatureID")
}
val resultRDD = OverlayAnalyst.overlay(polygonInRedLine, rangeRDD, targetFields, Array("plot"), intersect, 0.000001, isIniProcess = false)
spark中叠加分析后得到的FeatureRDD没有FeatureID,调用withFeatureID添加FeatureID,添加失败。添加不上,从而无法进行后续的分析操作。