AE traversal raster to implement reclassification of the raster (C # implementation)

Source: Internet
Author: User

There are many methods for reclassifying raster data. AE can be implemented in multiple ways, either by map algebra (implemented in RasterModel), IReclassOp, or Geoprocessor, it can even be implemented by traversing the raster. This is the most primitive method, but it may also be the most practical. The original raster Traversal method is used here. [Csharp] private void reclass (IRaster pRaster, float weight) {IRasterProps rasterProps = (IRasterProps) pRaster; // set the grid data starting point IPnt pBlockSize = new Pnt (); pBlockSize. setCoords (rasterProps. width, rasterProps. height); // select the entire range IPixelBlock pPixelBlock = pRaster. createPixelBlock (pBlockSize); // the upper left coordinate IPnt tlp = new Pnt (); tlp. setCoords (0, 0); // read The raster IRasterBandCollection pRasterBands = pRaster as IRaster BandCollection; IRasterBand pRasterBand = pRasterBands. item (0); IRawPixels pRawRixels = pRasterBands. item (0) as IRawPixels; pRawRixels. read (tlp, pPixelBlock); // sets the PixBlock value to an array System. array pSafeArray = pPixelBlock. get_SafeArray (0) as System. array; for (int y = 0; y <rasterProps. height; y ++) {for (int x = 0; x <rasterProps. width; x ++) {// int value = Convert. toInt32 (pSafeArray. getValue (x, y )); Byte value = Convert. ToByte (pSafeArray. GetValue (x, y); if (value! = 0) {pSafeArray. setValue (Byte) (value * weight), x, y) ;}} pPixelBlock. set_SafeArray (0, pSafeArray); // edit raster to write the updated value to IRasterEdit rasterEdit = pRaster as IRasterEdit; rasterEdit. write (tlp, pPixelBlock); rasterEdit. refresh ();}

Related Article

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.