Use ArcGISEngine to crop Raster Data

Source: Internet
Author: User
Use ArcGISEngine to crop Raster Data

Previous/next article 00:09:47/person type: ArcGISEngine Development

View (189)/comment (0)/score (0/0)

The ArcGIS Spatial Analysis extension module provides the ability to crop and extract raster data. In ArcGISEngine, you can call related GP tools to operate raster data.

  • Call the Extract By Polygon tool in Space Analysis ArcToolbox

Private void ExtractByPolygon ()

{

IVariantArray parameters = new VarArrayClass ();

String sDocPath = @ "C: \ filerastergdb. gdb \ raster"; // map document path

String sDocPath1 = @ "C: \ filerasteroutput. gdb \ outraster ";

Parameters. Add (sDocPath );

String ss1 = "'2017. 545160 944 '; '2017. 4639276.889 545216'; '2017. 242 4639266.57 '";;

Parameters. Add (ss1 );

Parameters. Add (sDocPath1 );

Parameters. Add ("INSIDE ");

IGeoProcessor2 gp = new GeoProcessorClass ();

Gp. OverwriteOutput = true;

IGeoProcessorResult pResult = null;

Try

{

PResult = gp. Execute ("ExtractByPolygon", parameters, null );

IWorkspaceFactory pFWSF = new ESRI. ArcGIS. DataSourcesGDB. FileGDBWorkspaceFactoryClass ();

ESRI. ArcGIS. Geodatabase. IWorkspace pWS = pFWSF. OpenFromFile (@ "C: \ filerasteroutput. gdb", 0 );

ESRI. ArcGIS. Geodatabase. IRasterWorkspaceEx pRasterWs = pWS as ESRI. ArcGIS. Geodatabase. IRasterWorkspaceEx;

IRasterDataset pRasterDataset = pRasterWs. OpenRasterDataset ("outraster ");

IRasterLayer pRasterLayer = new RasterLayerClass ();

PRasterLayer. CreateFromDataset (pRasterDataset );

AxMapControl1.AddLayer (pRasterLayer );

String mess = null;

For (int k = 0; k <gp. MessageCount; k ++)

{

Mess + = gp. GetMessage (k) + "\ n ";

}

MessageBox. Show (mess );

}

Catch (Exception err)

{

String msg = err. Message;

String mess = null;

For (int k = 0; k <gp. MessageCount; k ++)

{

Mess + = gp. GetMessage (k) + "\ n ";

}

MessageBox. Show (mess );

}

}

 

  • Call the IExtractionOp interface to crop raster data.

Public void ExtractionRasterData (IGeoDataset pGeoDataset, ESRI. ArcGIS. Geometry. ipolympus Gon pPolygone, bool binside)

{

ESRI. ArcGIS. SpatialAnalyst. IExtractionOp pExtractionOp = new ESRI. ArcGIS. SpatialAnalyst. RasterExtractionOpClass ();

ESRI. ArcGIS. Geodatabase. IGeoDataset pgooutput = pExtractionOp. Polygon (pGeoDataset, pPolygone, binside );

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.