资源描述:
《如东地理区位分析》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、二专题地图家乡地I专题地图人口密度代码PrivateSubUTButtonControl1_C1ick()DimpDocAsIMxDocument'操作文档的DimpLayerAsILayer'操作激活的图层DimpMapAsIMapDimpFeatLyrAsIFeatureLayer操作矢量图层DimpFeatClsDimpFcatCurAsTFeatureClass'操作属性表AsIFcaturcCursor,操作游标DimpFeatAsIFeature'操作记录DimdPOPAsDouble
2、'操作人口内容DimpPlgAsIPolygon'操作多边形DimpAreaAsTArea'操作区域,计算面积DimdPopDcnAsDouble'人口密度计算结果DimpFldAsIField'字段DimsNameAsString'属性定义(sNameJeng,sType,sPrecision,sScale)DimlengAsIntegerDimsTypeAsIntegerDimsPrecisionAsIntegerDimsScaleAsIntegersName二〃人口密度”long=15sTy
3、pe=esriFieldTypeDoublesPrecision二12sScale=3SetpFld二createFldC人口密度”,15,3,12,3),参数列表,新建字段MsgBoxpFld.Name'显示新建字段的名称'1,获取图层SetpDoc二ThisDocumentSetpLayer=pDoc.SelectedLayerSetpFeatLyr=pLayer'2,获取屈性表SetpFeatCls=pFeatLyr・FeatureClass'判断图层中的地物类型FeatCls.ShapeT
4、ype<>esTfpriGeometryPolygonThenMsgBox〃当前图层不是多边形图层”EndIf'判断图层类型IfNotLayerType(pLayer)=〃矢量”ThenMsgBox〃当前图层不是矢量”EndIf'3,判断人口密度字段是否存在b=IfFldExist(pFeatCls,〃人口密度”)IfNotbThenSetpFld=createFldC人口密度”,15,3,12,3)pFeatCls.AddFieldpFldEndTf'4,获取人口密度字段的顺序号DimIFldl
5、DAsIntegerIFIdID=pFeatCls.FindFieldC人口密度”)DimiPopIDAsIntegeriPopTD二pFeatCls.FindFieldf人口”)>5,计算人口密度SetpFeatCur=pFeatCls・Update(Nothing,False)SetpFeat=pFeatCur.NextFeature'判断图层是否为空DoUnti1pFeatTsNothingSetpPlg=pFeat・ShapeSetpArea=pPlgdPopDen=pFeat.Value
6、(iPopID)/pArea.AreapFeat.Value(IFIdID)二dPopDenpFeatCur.UpdateFeaturepFeatSetpFeat二pFeatCur.NextFeatureLoopMsgBox〃计算完成”EndSub'新建字段的调用函数1FunctioncreateFld(sNameAsString,lengAsInteger,sTypeAsInteger,sPrecisionAsInteger,sScaleAsInteger)AsTFieldDimpFldAsTF
7、ieldDimpFldEditAsIFicldEditSetpFld=NewFieldSetpFldEdit=pFldWithpFldEdit•Name二sName•Length二leng.Type=sType.Precision二sPrecision.Scale=sScaleEndWithSetcrcatcFid=pFldEndFunction'判断字段是否存在的调用函数2FundionIfTldExisi(pFeatClsAsTFeatureClass,sFldNamAsString)AsBo
8、oleanDimIFIdIDAsIntegerDimpFldnameAsStringIFIdID=pFeatCls.FindField(sFldNam)IfIFIdID二-1ThenIfFldExist二FalseElseIfFldExist二TrueEndIfEndFunction'判断图层类型的调用函数3FunctionLayerType(pLayerAsTLayer)AsStringDimsAsStringIfTvpeOfpLaverIsIFeatureLaverThens=