Esempio n. 1
0
 private IRasterLayer IntersectRaster(IRasterLayer rsterLayer, IPolygon polygon2)
 {
     //  获得与组合成的面相叠加的栅格
     if (radioBtnKJ.Checked && polygon2 != null)
     {
         ESRI.ArcGIS.SpatialAnalyst.IExtractionOp op = new ESRI.ArcGIS.SpatialAnalyst.RasterExtractionOpClass();
         IGeoDataset  dataset = op.Polygon((IGeoDataset)rsterLayer.Raster, polygon2, true);
         IRasterLayer layer   = new RasterLayerClass();
         layer.CreateFromRaster((IRaster)dataset);
         rsterLayer = layer;
     }
     return(rsterLayer);
 }
Esempio n. 2
0
        /// <summary>
        /// get a clip of a larger raster using the specified survey boundary as the cut out shape
        /// </summary>
        public static IGeoDataset ClipRasterByBndPoly(IGeoDataset RasterToClip, string SurveyID, ref string ErrorMessage)
        {
            IPolygon SurveyBoundary, SurveyEnvelopePoly, DEMEnvelopePoly;
            ESRI.ArcGIS.SpatialAnalyst.IExtractionOp ExtractOp;
            IGeoDataset ClippedRaster = null;

            SurveyBoundary = Util.GetSurveyBoundary(SurveyID, ref ErrorMessage);
            if (string.IsNullOrEmpty(ErrorMessage) == false) return null;

            SurveyEnvelopePoly = Util.EnvelopeToPolygon(SurveyBoundary.Envelope);
            DEMEnvelopePoly = Util.EnvelopeToPolygon(RasterToClip.Extent);

            if (((IRelationalOperator)DEMEnvelopePoly).Contains(SurveyEnvelopePoly) == false)
            {
                ErrorMessage = "The boundary polygon for SurveyID " + SurveyID
                    + " is out of range of the Raster extent.";
                return null;
            }

            try
            {
                ExtractOp = new ESRI.ArcGIS.SpatialAnalyst.RasterExtractionOpClass();
                ClippedRaster = ExtractOp.Polygon(RasterToClip, SurveyEnvelopePoly, true);
            }
            catch (Exception ex)
            {
                ErrorMessage = "Error occured while clipping raster to boundary of survey "
                    + SurveyID + ". " + ex.Message;
            }

            return ClippedRaster;
        }