RasterFunctionTemplate
Base Type: RasterFunction
A class for a template raster function.
Property |
Type |
Description |
---|---|---|
Arguments |
The raster function arguments in the template. | |
Function |
The raster function in the template. | |
Name |
string |
The name. |
PixelType |
The pixel type. |
Remarks
The raster function template can be used to chain multiple functions.
Examples
C#
//general setting
sampleImage_ImageServer imageSrv = new sampleImage_ImageServer();
imageSrv.Url = url;
sampleImage.GeoImageDescription geoImgDesc = new SOAPRasterFunctionTemplate.sampleImage.GeoImageDescription();
geoImgDesc.Height = 600;
geoImgDesc.Width = 800;
geoImgDesc.Interpolation = SOAPRasterFunctionTemplate.sampleImage.rstResamplingTypes.RSP_BilinearInterpolation;
ImageServiceInfo isInfo = imageSrv.GetServiceInfo();
geoImgDesc.Extent = isInfo.Extent;
//raster function variable
RasterFunctionVariable rfv = new RasterFunctionVariable();
rfv.Name = "ClipRaster1";
rfv.IsDataset = true;
rfv.IsDatasetSpecified = true;
//clip 1
ClipFunction clipFunction1 = new ClipFunction();
ClipFunctionArguments clipArgument1 = new ClipFunctionArguments();
EnvelopeN clipEnvelope1 = new EnvelopeN();
double xmin, xmax, ymin, ymax;
xmin = ((EnvelopeN)isInfo.Extent).XMin;
xmax = ((EnvelopeN)isInfo.Extent).XMax;
ymin = ((EnvelopeN)isInfo.Extent).YMin;
ymax = ((EnvelopeN)isInfo.Extent).YMax;
clipEnvelope1.XMin = xmin + (xmax - xmin) / 5;
clipEnvelope1.XMax = xmin + (xmax - xmin) * 4 / 5;
clipEnvelope1.YMin = ymin + (ymax - ymin) / 5;
clipEnvelope1.YMax = ymin + (ymax - ymin) * 4 / 5;
clipEnvelope1.SpatialReference = ((EnvelopeN)isInfo.Extent).SpatialReference;
clipArgument1.Names = new string[] { "ClippingGeometry", "ClippingType", "Raster" };
clipArgument1.Values = new object[] { clipEnvelope1, 1, rfv };
RasterFunctionTemplate rftClip1 = new RasterFunctionTemplate();
rftClip1.Name = "ExtractTemplate";
rftClip1.Function = clipFunction1;
rftClip1.Arguments = clipArgument1;
//clip 2
ClipFunction clipFunction = new ClipFunction();
ClipFunctionArguments clipArgument = new ClipFunctionArguments();
EnvelopeN clipEnvelope = new EnvelopeN();
//double xmin, xmax, ymin, ymax;
xmin = ((EnvelopeN)isInfo.Extent).XMin;
xmax = ((EnvelopeN)isInfo.Extent).XMax;
ymin = ((EnvelopeN)isInfo.Extent).YMin;
ymax = ((EnvelopeN)isInfo.Extent).YMax;
clipEnvelope.XMin = xmin;
clipEnvelope.XMax = (xmin + xmax) / 2;
clipEnvelope.YMin = ymin;
clipEnvelope.YMax = (ymin + ymax) / 2;
clipEnvelope.SpatialReference = ((EnvelopeN)isInfo.Extent).SpatialReference;
clipArgument.Names = new string[] { "ClippingGeometry", "ClippingType", "Raster" };//{ "ColorRamp", "Raster" };
clipArgument.Values = new object[] { clipEnvelope, 1, rftClip1 }; //1 inside, 2 outside
RasterFunctionTemplate rftClip = new RasterFunctionTemplate();
rftClip.Function = clipFunction;
rftClip.Arguments = clipArgument;
rftClip.Name = "RFTName";
//rendering rule
RenderingRule renderRule = new RenderingRule();
renderRule.Function = rftClip;
renderRule.VariableName = "ClipRaster1";
geoImgDesc.RenderingRule = renderRule;
ImageType imageType = new ImageType();
imageType.ImageFormat = esriImageFormat.esriImagePNG;
imageType.ImageReturnType = esriImageReturnType.esriImageReturnURL;
ImageResult imgResult = imageSrv.ExportImage(geoImgDesc, imageType);
This is a sample for using a predefined raster function template (rft.xml), as defined by the service publisher . The file structure will vary from service to service.
//define arguments (if necessary to overwrite default values)
RasterFunctionArguments argument = new RasterFunctionTemplateArguments();
argument.Names = new string[] { "Arg1", "Arg2" };
argument.Values = new object[] { "value1", "value2" };
RenderingRule renderRule = new RenderingRule();
renderRule.Arguments = argument;
renderRule.Name = "MyFunctionTemplateName";
renderRule.VariableName = "Raster";
geoImageDesc.RenderingRule = renderRule;
2/28/2020