Given that I have a valid raster "mExtractedraster"...
IRasterLayer rasterLayer = new RasterLayerClass();
// Customize how the raster renders.
IRasterStretchColorRampRenderer mRenderer = new RasterStretchColorRampRenderer();
mRenderer.ColorScheme = "Blue Light to Dark";
rasterLayer.Renderer = (IRasterRenderer)mRenderer;
// Compute the statistics for the raster.
IRasterCalcStatsHistogram m_calcStats = new RasterCalcStatsHistogramClass();
IStatsHistogram m_stHisto = new StatsHistogramClass();
m_calcStats.ComputeFromRaster(rasterLayer.Raster, 1, m_stHisto);
mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
...this code should correctly display the raster layer in the map control using the correct renderer. If I use the identify tool to explore the raster layer, I am getting the correct cell values however the raster looks like one that does not contain any statistics. Ideas? Thanks.
... View more
Hey all: How would I use a float that I hold in memory to generate a raster dataset? My first thought was to turn the float into a .FLT file and write the appropriate .HDR file to go along with it. Then I would use FloatToRaster. I wasn't quite sure how to turn the array into the file though, if it is even possible. Also, I have a TON of raster datasets to create, so I don't know if this would be the best method anyway. Does anyone have any suggestions? Thanks.
... View more
Hey all: I have been away from writing code for a little while. Would someone want to tell me why they think the following code would be breaking? Two things to note: One is that the IFieldsEdit does not give me a method AddField(IField) that I would suspect but rather a SetField(int, IField) method. Second, the call to create the raster catalog is failing with an error about trying to write to protected memory. I have seen the latter error before, but I don't remember how to fix it. Any guidance? Thanks in advance! // Open a workspace factory and create a new file GDB.
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
IWorkspaceFactory fileGdbWSF = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
IWorkspaceName fileGdbWSName = fileGdbWSF.Create("C:\\Data", "Testing5.gdb", null, 0);
IName wsName = (IName)fileGdbWSName;
IWorkspace fileGdbWS = (IWorkspace)wsName.Open();
IRasterWorkspaceEx rasWS = (IRasterWorkspaceEx)fileGdbWS;
IFields fields = new Fields();
IFieldsEdit fieldsEdit = (IFieldsEdit)fields;
fieldsEdit.FieldCount_2 = 2;
IField field1 = new Field();
IFieldEdit fieldEdit1 = (IFieldEdit)field1;
IField field2 = new Field();
IFieldEdit fieldEdit2 = (IFieldEdit)field2;
fieldEdit1.Name_2 = "FieldOne";
fieldEdit1.AliasName_2 = "Field One";
fieldEdit1.Type_2 = esriFieldType.esriFieldTypeString;
fieldEdit1.Editable_2 = true;
fieldEdit1.IsNullable_2 = true;
fieldEdit1.Length_2 = 20;
fieldEdit2.Name_2 = "FieldTwo";
fieldEdit2.AliasName_2 = "Field One";
fieldEdit2.Type_2 = esriFieldType.esriFieldTypeString;
fieldEdit2.Editable_2 = true;
fieldEdit2.IsNullable_2 = true;
fieldEdit2.Length_2 = 20;
// Why are these methods here instead of AddField(IField)?
rasWS.CreateRasterCatalog("MyCatalog", fields, "Shape", "Raster", null);
... View more