ArcGIS Pro栅格修改大小另存

System.Uri uri = new Uri("e:\\ESRI_GDB\\Southampton.gdb");

QueuedTask.Run(() =>
{

   FileGeodatabaseConnectionPath path = new FileGeodatabaseConnectionPath(uri);

   Geodatabase gdb = new Geodatabase(path);

   RasterDataset rasterDataset = gdb.OpenDataset("Raster_250");

   Raster raster = rasterDataset.CreateFullRaster();

   SpatialReference spatialReference = SpatialReferenceBuilder.CreateSpatialReference(27700);

   raster.SetSpatialReference(spatialReference);

   Envelope ext = EnvelopeBuilder.CreateEnvelope(400000, 100000, 450000, 150000, spatialReference); // select an area

   int W = raster.GetWidth(); // original raster is 4040 columns
   int H = raster.GetHeight(); // 3880 rows

   raster.SetWidth(500);   // try to set the size of the output raster
   raster.SetHeight(500);

   W = raster.GetWidth(); // still 4040 columns
   H = raster.GetHeight(); // correct at 500 rows

   raster.SetExtent(ext); // select teh geographic area of interest

   FileSystemConnectionPath connectionPath = new FileSystemConnectionPath(new System.Uri(@"C:\Dummy"),    FileSystemDatastoreType.Raster);
   FileSystemDatastore dataStore = new FileSystemDatastore(connectionPath);

   RasterStorageDef rasterStorageDef = new RasterStorageDef();
   rasterStorageDef.SetPyramidLevel(0); // don't want pyramids

   raster.SaveAs("bbtest.tif", dataStore, "TIFF", rasterStorageDef); // creates long thin distorted raster of the correct geographic area
  });

 

你可能感兴趣的:(ArcGIS Pro栅格修改大小另存)