Vector cropping grid (filtering) (C #)

Source: Internet
Author: User
Iclipfilter clipraster = New Clipfilterclass ();

// Add the polygons from the shapefile to the clip filer
Igeometry clipgeometry;
Ifeature feature;
For(IntI = 0; I <= featureclass. featurecount (Null)-1; I ++)
{
Feature = featureclass. getfeature (I );
Clipgeometry = (igeometry) feature. shape;
Clipraster. Add (clipgeometry );
}

// set the filter to the raster
ipixeloperation pixelop = (ipixeloperation) raster;
pixelop. pixelfilter = (ipixelfilter) clipraster;

// now we need to specify properties for the output. the output can
// be a file format or a Geodatabase. this sample supports output
// to file Geodatabase and personal Geodatabase.
// If the output is a file format and input raster does not contain nodata and the max value
// Of the pixel depth is being used. (for example 255 is used for
// 8 bit unsigned case ), output pixel depth needs to be promoted and nodata
// value need to set up properly.

Iworkspace workspace = openworkspace (outputfolder );
Irasterprops rasterprops = (irasterprops) raster;

If(Workspace. pathname. Contains (". GDB") =False)
{
Rasterprops. nodatavalue = 256;
Rasterprops. pixeltype = rstpixeltype. pt_ushort;
}

// Save the result out
Isaveas saveas = (isaveas) raster;
Saveas. saveas (outputfile, workspace, format );

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.