public void Adjust() { IRasterGeometryProc proc = new RasterGeometryProc(); proc.Reset(this.irasterLayer_0.Raster); if (this.DestPointCollection.PointCount == 1) { IPoint point = this.SourcePointCollection.get_Point(0); IPoint point2 = this.DestPointCollection.get_Point(0); double deltaX = point2.X - point.X; double deltaY = point2.Y - point.Y; proc.Shift(deltaX, deltaY, this.irasterLayer_0.Raster); } else if (this.DestPointCollection.PointCount == 2) { proc.TwoPointsAdjust(this.SourcePointCollection, this.DestPointCollection, this.OperatorLayer.Raster); } else if (this.DestPointCollection.PointCount >= 3) { proc.Warp(this.SourcePointCollection, this.DestPointCollection, this.GeoTransType, this.OperatorLayer.Raster); } proc.Register(this.OperatorLayer.Raster); proc = null; if (this.m_HookHelper.FocusMap != null) { (this.m_HookHelper.FocusMap as IActiveView).Refresh(); } }
static void Main(string[] args) { //ESRI License Initializer generated code. m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeAdvanced }, new esriLicenseExtensionCode[] { }); //ESRI License Initializer generated code. //Get a path to the raster workspace and create a RasterWorkspace object Type factoryType = Type.GetTypeFromProgID("esriDataSourcesRaster.RasterWorkspaceFactory"); IWorkspaceFactory workspaceFactory = Activator.CreateInstance(factoryType) as IWorkspaceFactory; IRasterWorkspace2 rasterWorkspace = (IRasterWorkspace2)workspaceFactory.OpenFromFile("\\\\Filepath\\ToRaster\\Folder", 0); IRasterDataset rasterDataset = rasterWorkspace.OpenRasterDataset("DEM_Resample.tif"); //Create a raster layer to get the raster object from it IRasterLayer rasterLayer = new RasterLayer(); rasterLayer.CreateFromDataset(rasterDataset); IRaster raster = rasterLayer.Raster; //Get the raster properties so we can modify them later and get details about them if we so choose. IRasterProps rasterProps = raster as IRasterProps; double cellSize = 60; //Declate a new spatial reference if you want to change the spatial reference used. ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironment(); ISpatialReference2 srReference = srFactory.CreateProjectedCoordinateSystem(26917) as ISpatialReference2; //Create an IRasterGeometryProc object as this has the projectFast method we are looking for. IRasterGeometryProc rasterGeometryProc = new RasterGeometryProc(); rasterGeometryProc.ProjectFast(rasterProps.SpatialReference, rstResamplingTypes.RSP_NearestNeighbor, ((object)cellSize), raster); //Create a new rasterBandCollection to store the raster in and save it there. IRasterBandCollection rasterBandCollection = raster as IRasterBandCollection; String outName = "NewImage.tif"; String outType = "TIFF"; rasterBandCollection.SaveAs(outName, ((IWorkspace)rasterWorkspace), outType); Console.WriteLine("DONE"); Console.ReadLine(); //Do not make any call to ArcObjects after ShutDownApplication() m_AOLicenseInitializer.ShutdownApplication(); }
static void Main(string[] args) { //ESRI License Initializer generated code. m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeAdvanced }, new esriLicenseExtensionCode[] { }); //ESRI License Initializer generated code. //Get a path to the raster workspace and create a RasterWorkspace object Type factoryType = Type.GetTypeFromProgID("esriDataSourcesRaster.RasterWorkspaceFactory"); IWorkspaceFactory workspaceFactory = Activator.CreateInstance(factoryType) as IWorkspaceFactory; IRasterWorkspace2 rasterWorkspace = (IRasterWorkspace2) workspaceFactory.OpenFromFile("\\\\Filepath\\ToRaster\\Folder", 0); IRasterDataset rasterDataset = rasterWorkspace.OpenRasterDataset("DEM_Resample.tif"); //Create a raster layer to get the raster object from it IRasterLayer rasterLayer = new RasterLayer(); rasterLayer.CreateFromDataset(rasterDataset); IRaster raster = rasterLayer.Raster; //Get the raster properties so we can modify them later and get details about them if we so choose. IRasterProps rasterProps = raster as IRasterProps; double cellSize = 60; //Declate a new spatial reference if you want to change the spatial reference used. ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironment(); ISpatialReference2 srReference = srFactory.CreateProjectedCoordinateSystem(26917) as ISpatialReference2; //Create an IRasterGeometryProc object as this has the projectFast method we are looking for. IRasterGeometryProc rasterGeometryProc = new RasterGeometryProc(); rasterGeometryProc.ProjectFast(rasterProps.SpatialReference, rstResamplingTypes.RSP_NearestNeighbor, ((object)cellSize), raster); //Create a new rasterBandCollection to store the raster in and save it there. IRasterBandCollection rasterBandCollection = raster as IRasterBandCollection; String outName = "NewImage.tif"; String outType = "TIFF"; rasterBandCollection.SaveAs(outName, ((IWorkspace)rasterWorkspace), outType); Console.WriteLine("DONE"); Console.ReadLine(); //Do not make any call to ArcObjects after ShutDownApplication() m_AOLicenseInitializer.ShutdownApplication(); }
public void Save() { IRasterProps props = (IRasterProps)this.irasterLayer_0.Raster; if (this.m_HookHelper.FocusMap != null) { props.SpatialReference = this.m_HookHelper.FocusMap.SpatialReference; } IRasterGeometryProc proc = new RasterGeometryProc(); IRaster pRaster = this.irasterLayer_0.Raster; (this.irasterLayer_0 as IDataLayer2).Disconnect(); proc.Register(pRaster); this.irasterLayer_0.CreateFromRaster(pRaster); this.DestPointCollection.RemovePoints(0, this.DestPointCollection.PointCount); this.SourcePointCollection.RemovePoints(0, this.SourcePointCollection.PointCount); if (this.m_HookHelper.FocusMap != null) { (this.m_HookHelper.FocusMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, this.OperatorLayer, null); } }