IWorkspaceFactory wsf = new RasterWorkspaceFactoryClass(); IRasterWorkspace rasterWS = (IRasterWorkspace)wsf.OpenFromFile(foldername, 0); IRasterDataset rasterDS = rasterWS.OpenRasterDataset("n42.dt0"); //DTED Level 0 file
IRaster raster = rasterDS.CreateDefaultRaster(); RasterSurfaceClass rsc = new RasterSurfaceClass(); rsc.PutRaster(raster); [INDENT]rsc.GetElevation(point);[/INDENT] [INDENT]rsc.GetLineOfSight(blah, blah, blah);[/INDENT]
Solved! Go to Solution.
IRasterCollection rc = (IRasterCollection) new MosaicRasterClass(); #region Add some IRasterDataset to the rc (IRasterCollection) rc.Insert(0, rasterDataset0); rc.Insert(1, rasterDataset1); rc.Insert(2, rasterDataset2); rc.Insert(3, rasterDataset3); #endregion ISaveAs2 save = (ISaveAs2) rc; IRasterStorageDef st = new RasterStorageDefClass(); IRasterStorageDef3 store = (IRasterStorageDef3)st; store.CompressionType = esriRasterCompressionType.esriRasterCompressionUncompressed; store.Tiled = false; IRasterDataset resultDataset = save.SaveAsRasterDataset("ResultDTED.dt0", _workspace_, "DEM", store);
Hello
I can get Linear Line of Sight from a single DTED file; which had beed opened by:IWorkspaceFactory wsf = new RasterWorkspaceFactoryClass(); IRasterWorkspace rasterWS = (IRasterWorkspace)wsf.OpenFromFile(foldername, 0); IRasterDataset rasterDS = rasterWS.OpenRasterDataset("n42.dt0"); //DTED Level 0 file
Single DTED file means that both observer and target are in the DTED file's area.
Well, the problem occurs when I load more than one DTED files and want to use these functions:IRaster raster = rasterDS.CreateDefaultRaster(); RasterSurfaceClass rsc = new RasterSurfaceClass(); rsc.PutRaster(raster); [INDENT]rsc.GetElevation(point);[/INDENT] [INDENT]rsc.GetLineOfSight(blah, blah, blah);[/INDENT]
If observer is in a DTED file and target is in another DTED file, GetLineOfSight function fails obviously.
How can I merge two RasterDataset to give rsc.PutRaster() function one single raster?
Or
How can I put more than one raster in RasterSurfaceClass?
Thank you
Sincerely
I think you are looking for a mosaic: http://resources.arcgis.com/en/help/main/10.1/index.html#//009t000000n6000000
After a lot of googling, I found out that I should create a IRasterDatasetEdit3, copy first DTED's IRasterDataset to it and then, append other DTEDs using IRasterDatasetEdit3.Mosaic function. Here is my code's screenshot:
[ATTACH=CONFIG]23074[/ATTACH]
Unfortunately Mosaic(IRaster raster, double tolerance) function fails at run-time execution. I have no idea why. Does anyone has idea?
By the way, that's tolerance (second parameter) in Mosaic?!
Please guide me to this 😞
Thank you
Sincerely
try { // code that is failing } catch( Exception e) { MessageBox.Show( e.ToString()); }
After a lot of googling, I found out that I should create a IRasterDatasetEdit3, copy first DTED's IRasterDataset to it and then, append other DTEDs using IRasterDatasetEdit3.Mosaic function. Here is my code's screenshot:
[ATTACH=CONFIG]23074[/ATTACH]
Unfortunately Mosaic(IRaster raster, double tolerance) function fails at run-time execution. I have no idea why. Does anyone has idea?
By the way, that's tolerance (second parameter) in Mosaic?!
Please guide me to this 😞
Thank you
Sincerely
IRasterDatasetEdit3 rasterDSE = (IRasterDatasetEdit3)rasterDS[0].CreateDefaultRaster(); for(int i = 1; i < rasterDS.Count; i++ ) { rasterDS.CreateDefaultRaster(); rasterDSE.Mosaic((IRaster)rasterDS.CreateDefaultRaster(), 1000); }
rasterDS.CreateDefaultRaster(); rasterDSE.Mosaic((IRaster)rasterDS.CreateDefaultRaster(), 1000);
IRaster r = rasterDS.CreateDefaultRaster(); rasterDSE.Mosaic(r, 1000);
rasterDSE.Mosaic(rasterDS.CreateDefaultRaster(), 1000);
IRaster r = null; try { r = rasterDS.CreateDefaultRaster(); rasterDSE.Mosaic(r, 1000); } finally { if( r != null ) Marshal.ReleaseComObject( r ); }
Actually, the first CreateDefaultRaster was mistake (I put it there for my own debugging).
Now, my code is like this:
[ATTACH=CONFIG]23082[/ATTACH]
But, still the same problem. Fails at Mosaic function. I have no idea about it's second paramter. I just give random numbers 😐
Why there isn't any explanation or sample about this function?!
ArcGIS bored me a lot 😞
Thank you for your reply; Jason
Sincerely
Ah! CreateDefaultRaster() returns a raster, not a raster dataset!
You need a raster dataset to create the mosaic:
http://edndoc.esri.com/arcobjects/9.2/NET/dd494eb7-b56b-4e7a-adeb-0eccc1f9765c.htm
Once you create the raster dataset, you can cast it to IRasterDatasetEdit and use the mosaic function to add your rasters (created using the CreateDefaultRaster() method.
Make sense?
IWorkspaceFactory wsf = new RasterWorkspaceFactoryClass(); IRasterWorkspace rasterWS = (IRasterWorkspace)wsf.OpenFromFile(foldername, 0); List<IRasterDataset> rasterDS = new List<IRasterDataset>(); rasterDS.Add(rasterWS.OpenRasterDataset(DTED_filename)); //"n34.dt0" for ex.