I would like to enumerate raster datasets in folder where other process created them. Something like in ArcObjects:
pDatasets = pWorkspace.get_Datasets(esriDatasetType.esriDTRasterDataset);
I have found information about GetItems here:
But I do not know how to get starting item from my folder path, what factory and what item to use.
If you have a Geodatabase object, you can call Geodatabase.GetDefinitions<RasterDatasetDefinition>. This will return a list of RasterDatasetDefinition objects.
I can tell you how to obtain a Geodatabase object if you tell me where you are starting from (e.g., FeatureLayer).
I hope this helps,
I am starting from folder path on disk. ArcMap application creates rasters and I use ArcGIS Pro to visualize them.
I have tried to create a new FileSystemDatastore using the FileSystemConnectionPath, but compiler can’t cast FileSystemDatastore to Geodatabase.
I think that I must add my folder to Project first ant then get back from Project my folder as FolderConnectionProjectItem.
Then use GetItems from FolderConnectionProjectItem to get my rasters and etc.
I will try to do that.
I think I found solution, but I don't know if it is the best. The way of enumerating I described in previous reply. This is code of my solution:
// Add a folder to the Project
var folderToAdd = ItemFactory.Instance.Create(sResultsPath);
await QueuedTask.Run(() => Project.Current.AddItem(folderToAdd as IProjectItem));
// find the folder project item
FolderConnectionProjectItem folder = Project.Current.GetItems<FolderConnectionProjectItem>().FirstOrDefault(f => f.Path.Equals(sResultsPath, StringComparison.CurrentCultureIgnoreCase));
if (folder == null) return;
// do the search
IEnumerable<Item> folderFiles = null;
await QueuedTask.Run(() => folderFiles = folder.GetItems().Where(f => f.Type == "Raster Dataset"));
foreach (Item item in folderFiles)
Go ahead and try it; it looks like it should work.
We are investigating adding the ability to iterate through datasets of a file system data store, but that would be Pro 2.5 at the absolute earliest.
Note that this also works for shapefiles when you supply "Shapefile" in the f.Type search string. I have read some posts saying that listing shapefiles in a file system data store is not supported. Developing on 2.6.3.