|
技术资料:确定两区域间叠加部分面积大小:
以下代码首先创建两区域,通过IntersectFeatures方法确定叠加区域,再比较叠加区域与某一区域面积比
Private Sub Command1_Click()
Dim pts As New Points
Dim pts2 As New Points
Dim reg As New Feature
Dim reg2 As New Feature
Dim overlap As Feature
'Create a Temp layer
Map1.Layers.CreateLayer ("Temp")
'Setting the Coordinates for reg (the first region)
pts.AddXY -78.695, 45.46
pts.AddXY -74.177, 45.172
pts.AddXY -74.432, 42.55
pts.AddXY -78.003, 42.523
'Setting the Coordinates for reg2 (the second region)
pts2.AddXY -76.509, 44.071
pts2.AddXY -71.261, 43.939
pts2.AddXY -71.371, 42.261
pts2.AddXY -76.254, 42.655
'Creating reg
Set reg = Map1.FeatureFactory.CreateRegion(pts, Map1.DefaultStyle)
'Adding reg to the Map
Set reg = Map1.Layers("Temp").AddFeature(reg)
'Creating reg2
Set reg2 = Map1.FeatureFactory.CreateRegion(pts2, Map1.DefaultStyle)
'Adding reg2 to the Map
Set reg2 = Map1.Layers("Temp").AddFeature(reg2)
'Creating overlap, where the two regions overlap
Set overlap = Map1.FeatureFactory.IntersectFeatures(reg, reg2)
'Changing the region style of overlap
overlap.Style.RegionColor = miColorYellow
'Adding overlap to the Map
Set overlap = Map1.Layers.Item("Temp").AddFeature(overlap)
MsgBox reg.Area 'Area for first region
MsgBox reg2.Area 'Area for second region
MsgBox overlap.Area 'Area for overlap region
' Percentage of overlap area compared to the second region
MsgBox (overlap.Area / reg2.Area) * 100
End Sub |
|