Band information statistics of raster data in ArcGIS Engine

Source: Internet
Author: User

Open the workspace (File) where the raster file is located, obtain all its bands, and access each band.
You can use the computestatsandhist () function to calculate a histogram or statistical information in a band.
(Large data volumes may take a long time)

Iworkspacefactory workspacefactory = new rasterworkspacefactory ();
Iworkspace;
Workspace = workspacefactory. openfromfile (filepath, 0 );

Irasterworkspace rastwork = (irasterworkspace) Workspace;
Irasterdataset rastdataset = rastwork. openrasterdataset (pathbox. Text. substring (pathbox. Text. lastindexof ("\") + 1 ));
Irasterdataset2 RD2 = rastdataset as irasterdataset2;
Iraster raster = rd2.createfullraster ();
Irasterbandcollection rb= (irasterbandcollection) raster;
For (INT I = 0; I <RBC. Count; I ++)
{
Irasterband RB = RBC. item (I );
Bool tmpbool;
RB. hasstatistics (Out tmpbool );
If (! Tmpbool)
RB. computestatsandhist ();
Irasterhistogram RH = RB. histogram;
Irasterstatistics rs = RB. Statistics;
}

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.