首页 / 浏览问题 / 组件GIS / 问题详情
spark中叠加分析无法添加FeatureID
18EXP 2021年09月24日
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,添加失败。添加不上,从而无法进行后续的分析操作。

1个回答

构造一个新FeatureRDD, 第三个参数传入true
1,560EXP 2021年09月26日
...