GIS¶þ´Î¿ª·¢ÊµÑ鱨¸æ ÏÂÔØ±¾ÎÄ

5 ʵÑéÎ壺GIS·ÖÎö

5.1 ʵÑéÄ¿µÄ

? Á˽âGIS¿Õ¼ä·ÖÎöµÄÄÚÈÝ ? ÕÆÎÕ¿Õ¼ä¹ØÏµ²éѯ·½·¨ ? ÕÆÎÕ¿Õ¼äÍØÆË·ÖÎö·½·¨ ? ÕÆÎÕ¿Õ¼äÊý¾Ýͳ¼Æ·½·¨

5.2 ʵÑéÄÚÈÝ

? ʵÏÖ¿Õ¼ä¹ØÏµ²éѯ³ÌÐò ? ʵÏÖ»º³åÇø·ÖÎö³ÌÐò ? ʵÏÖÒªËØÍ³¼Æ³ÌÐò

5.3 ʵÑé²½ÖèÓë½á

1.ÔÚÖ÷´°Ìå²Ëµ¥À¸Ìí¼ÓÒ»¸ö¿Ø¼þÎı¾¡°GIS·ÖÎö¡±£¬Ìí¼ÓÏÂÀ­²Ëµ¥£¬Îı¾¡°¿Õ¼ä²éѯ¡±£¬¿Ø¼þÃû¡°miSpatilFilter¡±

2.Ìí¼ÓеÄÀà¡°Analysis.cs¡± 3.Ìí¼ÓÀà¿âÒýÓÃ

4.Ìí¼Ó¡°¿Õ¼ä²éѯ¡±º¯Êý£¬´úÂëÈçÏÂ

public bool QueryIntersect(string srcLayerName, string tgtLayerName, IMap iMap, esriSpatialRelationEnum spatialRel) {

DataOperator dataOperator = new DataOperator(iMap); //¶¨Òå²¢¸ù¾Ýͼ²ãÃû³Æ»ñȡͼ²ã¶ÔÏó IFeatureLayer iSrcLayer = (IFeatureLayer)dataOperator.GetLayerByName(srcLayerName); IFeatureLayer iTgtLayer = (IFeatureLayer)dataOperator.GetLayerByName(tgtLayerName); //ͨ¹ý²éѯ¹ýÂË»ñÈ¡Continents²ãÖÐÑÇÖ޵ļ¸ºÎ IGeometry geom; IFeature feature;

IFeatureCursor featCursor; IFeatureClass srcFeatClass;

IQueryFilter queryFilter = new QueryFilter();

20

queryFilter.WhereClause = \ÉèÖòéѯÌõ¼þ featCursor = iTgtLayer.FeatureClass.Search(queryFilter, false); feature = featCursor.NextFeature();

geom = feature.Shape;//»ñÈ¡ÑÇÖÞͼÐμ¸ºÎ

//¸ù¾ÝËùÑ¡ÔñµÄ¼¸ºÎ¶Ô³ÇÊÐͼ²ã½øÐÐÊôÐÔÓë¿Õ¼ä¹ýÂË srcFeatClass = iSrcLayer.FeatureClass;

ISpatialFilter spatialFilter = new SpatialFilter(); spatialFilter.Geometry = geom;

spatialFilter.WhereClause = \È˿ڵȼ¶µÈÓÚ5µÄ³ÇÊÐ spatialFilter.SpatialRel = (ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum)spatialRel; //¶¨ÒåÒªËØÑ¡Ôñ¶ÔÏó£¬ÒÔÒªËØËÑË÷ͼ²ã½øÐÐʵÀý»¯

IFeatureSelection featSelect = (IFeatureSelection)iSrcLayer; //ÒÔ¿Õ¼ä¹ýÂËÆ÷¶ÔÒªËØ½øÐÐÑ¡Ôñ£¬²¢½¨Á¢ÐÂÑ¡Ôñ¼¯ featSelect.SelectFeatures(spatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false); return true; }

5.Ìí¼Ó¡°¿Õ¼ä²éѯ¡±µã»÷ʼþÏìÓ¦º¯Êý£¬´úÂëÈçÏÂ

private void miSpatilFilter_Click(object sender, EventArgs e) {

MapAnalysis mapAnalysis = new MapAnalysis(); mapAnalysis.QueryIntersect(\Cities\\axMapControl1.Map, esriSpatialRelationEnum.esriSpatialRelationIntersection); IActiveView activeView;

activeView = axMapControl1.ActiveView;

activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, 0, axMapControl1.Extent); }

6.ʵÑéÔËÐнá¹ûÈçÏÂ

21

7.Ìí¼Ó¡°GIS·ÖÎö¡±µÄÏÂÀ­¿Ø¼þ£¬Îı¾¡°»º³åÇø·ÖÎö¡±£¬¿Ø¼þÃû¡°miBuffer¡± 8.Ìí¼Ó¡°»º³åÇø·ÖÎö¡±º¯Êý£¬´úÂëÈçÏÂ

public bool Buffer(string layerName, string sWhere, int iSize, IMap iMap) {

//¸ù¾Ý¹ýÂËÌõ¼þ»ñÈ¡³ÇÊÐÃû³ÆÎª±³¾°µÄ³ÇÊÐÒªËØ¼¸ºÎ IFeatureClass featClass; IFeature feature; IGeometry iGeom;

DataOperator dataOperator = new DataOperator(iMap); IFeatureLayer featLayer (IFeatureLayer)dataOperator.GetLayerByName(layerName); featClass = featLayer.FeatureClass;

IQueryFilter queryFilter = new QueryFilter(); queryFilter.WhereClause = sWhere; IFeatureCursor featCursor;

featCursor = (IFeatureCursor)featClass.Search(queryFilter, false); int count = featClass.FeatureCount(queryFilter); feature = featCursor.NextFeature(); iGeom = feature.Shape; /////////////////

ITopologicalOperator ipTO = (ITopologicalOperator)iGeom; IGeometry iGeomBuffer = ipTO.Buffer(iSize); ///////////////////

ISpatialFilter spatialFilter = new SpatialFilter(); spatialFilter.Geometry = iGeomBuffer;

spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIndexIntersects; //////////////////////////////////

IFeatureSelection featSelect = (IFeatureSelection)featLayer; featSelect.SelectFeatures(spatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false); return true; }

9.Ìí¼Ó¡°»º³åÇø·ÖÎö¡±µã»÷ʼþÏìÓ¦º¯Êý£¬´úÂëÈçÏ private void miBuffer_Click(object sender, EventArgs e) {

MapAnalysis mapAnalysis = new MapAnalysis(); mapAnalysis.Buffer(\Cities\\axMapControl1.Map);

IActiveView activeView;

activeView = axMapControl1.ActiveView;

activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, axMapControl1.Extent); }

10.ʵÑéÔËÐнá¹ûÈçÏÂ

22

=

1,

0,

11.Ìí¼Ó¡°GIS·ÖÎö¡±µÄÏÂÀ­¿Ø¼þ£¬Îı¾¡°ÒªËØÍ³¼Æ¡±£¬¿Ø¼þÃû¡°miStatistic¡± 12.Ìí¼Ó¡°ÒªËØÍ³¼Æ¡±º¯Êý£¬´úÂëÈçÏ ////////////ÒªËØÍ³¼Æ

public string Statistic(string layerName, string fieldName, IMap iMap) {

DataOperator dataOperator = new DataOperator(iMap); IFeatureLayer featLayer = (IFeatureLayer)dataOperator.GetLayerByName(layerName); ///

IFeatureClass featClass = featLayer.FeatureClass; IDataStatistics dataStatistic = new DataStatistics(); IFeatureCursor featCursor;

featCursor = featClass.Search(null, false); ICursor cursor = (ICursor)featCursor; dataStatistic.Cursor = cursor;

///////Ö¸¶¨Í³¼Æ×Ö¶ÎÎªÃæ»ý×ֶΣ¬Í³¼Æ³ö×îÐ¡Ãæ»ý¡¢×î´óÃæ»ý¼°Æ½¾ùÃæ»ý dataStatistic.Field = fieldName; IStatisticsResults statResult;

statResult = dataStatistic.Statistics; double dMax; double dMin; double dMean;

dMax = statResult.Maximum; dMin = statResult.Minimum; dMean = statResult.Mean; string sResult;

sResult = \×î´óÃæ»ý\×îÐ¡Ãæ»ý\ƽ¾ùÃæ»ý\ return sResult; }

13.Ìí¼Ó¡°ÒªËØÍ³¼Æ°¡¡±µã»÷ʼþÏìÓ¦º¯Êý£¬´úÂëÈçÏÂ

23