为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

[解说]猎取arcgis中polygon的中间点坐标

2018-08-06 8页 doc 25KB 5阅读

用户头像

is_682974

暂无简介

举报
[解说]猎取arcgis中polygon的中间点坐标[解说]猎取arcgis中polygon的中间点坐标 获取ARCGIS中polygon的中心点坐标 获取ARCGIS中polygon的中心点坐标(基于ArcGIS Desktop 9.3) 2009-05-17 11:08 大家好 我是GIS理想 这次我们研究下怎样获取ARCGIS中polygon 的中心点坐标 其实这个问题很早就遇到了 也没来得及总结 群里也有友友们在询 问 这里集中解决一下啦 不妥之处 还请大家批评指正~~~ 下面是arcgis help里的讲解(这段是别人整的 貌似有点问题 我先 贴下 后面我...
[解说]猎取arcgis中polygon的中间点坐标
[解说]猎取arcgis中polygon的中间点坐标 获取ARCGIS中polygon的中心点坐标 获取ARCGIS中polygon的中心点坐标(基于ArcGIS Desktop 9.3) 2009-05-17 11:08 大家好 我是GIS理想 这次我们研究下怎样获取ARCGIS中polygon 的中心点坐标 其实这个问题很早就遇到了 也没来得及 群里也有友友们在询 问 这里集中解决一下啦 不妥之处 还请大家批评指正~~~ 下面是arcgis help里的讲解(这段是别人整的 貌似有点问题 我先 贴下 后面我提供了解决办法): Adding the x,y coordinates of the centroid of a polygon layer to a new field 1. Optionally, start an edit session in ArcMap. Calculating a field is faster outside of an edit session, but you won't be able to undo the calculation. 2. Open the attribute table of the layer of the layer you want to edit. 3. Right-click the field heading for the X field (if there is no X field you can add a new field by clicking the options button and selecting the new field option). 4. Click Calculate Values. 5. Check Advanced. 6. Type the following VBA statement in the first text box. Dim dblX As DoubleDim pArea As IAreaSet pArea = [Shape]dblX = pArea.Centroid.X 7. Type the variable dblX in the text box directly under the X field name. 8. Click OK. You can repeat the same process for updating a field with the Y coordinates for the centroid point of each polygon in the layer. ? The property X returns a field type of double. For best results, your X field should also be a double field type. 下面我简要的翻译下 不敢保证百分百正确哈 呵呵 其实这些小问题 大家也都能看得懂。。。。。。 在计算面的中心点坐标的时候 用的是字段计算器(当然了还有其他方法) 第一步 添加X Y字段 注意在对面图层添加字段的时候 图层不能是可编辑状态 也就是说Editor下面不要选择开始编辑状态即可 第二步 选择编辑 右键图层打开属性表 第三步 右键X字段表头 选择字段计算器 第四步 选中Advanced 第五步 编写VBA代码 : Dim dblX As Double Dim pArea As IArea set pArea = [Shape] dblX = pArea.Centroid.y 然后在下面一栏里直接填上“dblX” 点击OK 即可 为了取得更好的效果 建议在字段的声明类型与vba类型一致 下面我介绍另外一个方法 不用写VBA代码了 因为属性表里操作已 经为大家准备好了 就是修改上面第三步的操作 不要选择字段计算器 选择计算几何要 素(calculate Geometry) 然后在Property下拉列表框里选择相应的属性即可 显然这里默认的计算有面积 周长 中心坐标XY 其他操作就与上面的一样了 很明显这样的话不用书写VBA代码了 稍微简单一点 不过本人还是推荐大家用VBA 毕竟这样有助与 对AE的理解 对搞开发有帮助的 ~~~吼吼 对了 大家可以直接在HELP里查找 这里面对VBA代码说的也很详细 的 我这里也贴出来一点供大家参考 不翻译了哈 很简单的 How to use Visual Basic code to calculate fields based on area, length, perimeter, etc. You can use Visual Basic code in the Advanced box in the Field Calculator dialog to calculate fields using geometric measurements. Although the easiest way to perform these calculations is to use the Calculate Geometry dialog described above, there may be situations where you want to use Visual Basic code to perform these calculations in the Field Calculator instead. These examples show how to do this. 1. These code examples return a value of type 'double', so use them to calculate either an existing field of type 'double' or a new field of type 'double' you've added to the table. 2. Check Advanced. You'll see two empty text entry boxes. 3. Enter one of these four line code examples into the topmost box, the one labeled 'Pre-Logic VBA Script Code'. Tip: you can select the code in this help topic, right-click and choose Copy, and then paste it into the box. To calculate area: Dim Output as double Dim pArea as Iarea Set pArea = [shape] Output = pArea.area To calculate length or perimeter (depending on whether the features are lines or polygons): Dim Output as double Dim pCurve as ICurve Set pCurve = [shape] Output = pCurve.Length To add the x coordinate of points: Dim Output As Double Dim pPoint As IPoint Set pPoint = [Shape] Output = pPoint.X To add the x coordinate of polygon centroids: Dim Output As Double Dim pArea As IArea Set pArea = [Shape] Output = pArea.Centroid.X 4. Type the variable Output into the second text box. Do not enclose it in quotes or brackets. 5. Click OK The units of the calculated values will be the units that your features are stored in, not the map units or display units of the data frame you are currently working with. So if your data is stored in feet, the calculated values will be in feet. If you want the calculated data to be in different units than the data's units, you could either add a conversion into the calculation expression, or (more simply) project your data into a coordinate system that uses the units you want the values to be in, and then perform the calculatio 最后我贴出来一些DESKTOP里常用的VBA代码吧 没有一一验证: (下面代码转载自集思学院) 特点: 1推荐给不会使用AO的朋友 2可以保存为CAL文件以备下次方便使用 使用方法 1打开属性表,选择计算的字段,右点选择Calculate Values; 2.选择“是”,进入Field Calculator; 2选择Advance选项; 3 在Pre-Logic VBA Script Code编辑框中输入VBA代码; 4在下面编辑框中输入赋值部分. 1--点坐标X VBA部分: Dim pGeo As IGeometry Set pGeo = [Shape] Dim pPoint As IPoint Set pPoint = pGeo 赋值部分: pPoint.X 2--点坐标Y VBA部分: 同上 赋值部分: pPoint.Y 坐标值为文件存储的固有值,和是否使用On the Fly坐标表示无关。返回当前显示的坐标值参看8,9 3--多边形周长 VBA部分: Dim pGeo As IGeometry Set pGeo = [Shape] Dim pPolygon As IPolygon Set pPolygon = pGeo 赋值部分: pPolygon.Length 4--多边形面积 VBA部分: Dim pGeo As IGeometry Set pGeo = [Shape] Dim pPolygon As IPolygon Set pPolygon = pGeo Dim pArea As IArea Set pArea = pPolygon 赋值部分: pArea.Area 5--多边形重心X VBA部分: Dim pGeo As IGeometry Set pGeo = [Shape] Dim pPolygon As IPolygon Set pPolygon = pGeo Dim pArea As IArea Set pArea = pPolygon Dim pPoint As IPoint Set pPoint = pArea.Centroid 赋值部分: pPoint.X 6--多边形重心Y VBA部分: 同上 赋值部分: pPoint.Y 7--Polyline长度 VBA部分: Dim pGeo As IGeometry Set pGeo = [Shape] Dim pPolyline As IPolyline Set pPolyline = pGeo Dim pCurve As IPolycurve Set pCurve = pPolyline 赋值部分: pCurve.Length 8--表示点坐标X VBA部分: Dim pDoc As IMxDocument Set pDoc = ThisDocument Dim pSpRef As ISpatialReference Set pSpRef = pDoc.FocusMap.SpatialReference Dim pClone As IClone Set pClone = [Shape] Dim pGeo As IGeometry Set pGeo = pClone.Clone Dim pPoint as IPoint Set pPoint = pGeo pGeo.Project pSpRef 赋值部分: pPoint.X 9--表示点坐标Y VBA部分: 同上 赋值部分: pPoint.Y
/
本文档为【[解说]猎取arcgis中polygon的中间点坐标】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索