Melanie
Recent Posts
Using tiled images with coordinates stored in a table
There’s a lot of tiled imagery out there that gets delivered to people without any coordinates stored with the files. Often the coordinate information exists but it’s stored in a table. So how do you view it in ArcGIS. Continue reading
Color balancing GeoEye imagery
Recently, I acquired two scenes of GeoEye imagery. They were provided as 7 different images. I opened the properties for each image, by clicking the raster product icon in the Catalog window and looked at the Key Metadata tab to … Continue reading
How to view tiled images from GeoEye as one image
Recently, I needed to order some imagery over an area in Bolivia. I searched a few provider databases and discovered that GeoEye had the best coverage in my area. Below, my area of interest is shown by the red square. … Continue reading
Displaying imagery with appropriate band name labels
At 10.1, ArcGIS is more knowledgeable about the names of bands in the supported satellite imagery. You may have noticed this if you’ve added such an image to your map document by selecting the raster product in the Catalog window and dragging … Continue reading
Come meet the Raster team at the 2012 Esri Developer Summit
Come meet the Raster team at the 2012 Esri Developer Summit
This year’s Esri Developer Summit will take place from March 26th to March 29th at the Palm Springs Convention Center.
More information about the 2011 Developer Summitt
View the Agenda
Come by and meet the members of the Raster Team, whether you have a question, or just want to meet some of the team. There are several way to meet us: you can come by the Showcase Area, you can attend our Technical Workshops or Demo Theaters, or you can join us at the Meet the Team event. Continue reading
For those using Esri Grid
The Esri Grid format for storing raster data has been around for…well, longer than this writer has been doing GIS. But we keep learning about things that need to be added to the documentation. I’m sure those original Grid users could probably tell me more than I ever wanted to know about the format, but here’s a limitation that was news to me.
The name of a Grid has certain limitations, but did you also know that there’s a limit to the number of Grids that can be stored in a workspace? The following lists the theoretical maximum number of Grid datasets that can be stored in a single workspace directory:
- less than 5000 floating point Grids, or
- less than 3333 integer Grids, with VATs (less than 5000 if no VATs), or
- less than 10000 Grid stacks
The preceding numbers are the theoretical maximums. If you have a process that will create interim Grids (and therefore files in the INFO directory) these numbers will be less. Additionally, if you are storing a mix of files, such as Grids and coverages, you will store fewer.
These numbers relate to the number of files in the Grid folder that store information in the INFO directory. The limit is 10,000 (well, 9,999), but it’s not the total number of files in an INFO directory, it’s the number of files pointing to the files in the INFO directory. For each Grid, there are two files in the Grid’s folder pointing to files in the INFO folder: the BND (boundary) files, and STA table (statistics) files (9999/2?5000). When a Grid has a VAT, this also points to files in the INFO directory, so the number that can be stored is reduced again (9999/3?3333). A Grid stack only has a single file which points to the INFO directory (9999/1?9999).
You can get a count of the number of files in an INFO directory using Windows Explorer.
- Navigate to the INFO directory.
- Select all the *.dat files (each Grid file points to a .nit and a .dat file).
- Right-click and select Properties.
This will give you the count of files. Regardless of the data is in the directory (Grids, stacks, coverages, etc.), when that number gets to 9999, the INFO directory is full and you’ll get an error message to the effect of: “Fatal Error: (INFDEF) directory full”. If you happen to come across this limit, you can either create a new workspace to work in, or remove any data that is no longer needed.
Melanie Harlow
How to open a raster dataset in code
There are several ways to open datasets (including raster datasets and mosaic datasets) using code. This is an easy task if you already know what kind of dataset you are trying to open. In the sample case here the user only provides a string, the code needs to do the rest.
My input form looks like this:
In the code I get the text string from the text box and pass it to my function to open the data. The goal is to return an opened dataset, or null, if nothing was found.
private IDataset OpenDataset(string fullPath)
{
IWorkspace ws = null;
IDataset dataset = null;
/* Main logic here */
return dataset;
}
Next I check if the path fulfills my requirements. It would be easy to extend this for other paths, such as URLs.
if (fullPath.Contains("\"))
{
/* Logic to open the data */
}
else{ MessageBox.Show("Invalid input string"); }
Assuming that the input path is acceptable, I check to determine what kind of data it is. First, I split the string into the path and the dataset name. Then I parse the path string to see what kind of workspace is given. For example, a file geodatabase will have a .gdb in the string.
string sWs = "", sDs = ""; sWs = System.IO.Path.GetDirectoryName(fullPath);
sDs = System.IO.Path.GetFileName(fullPath);
/* Data is in a personal geodatabase */
if (sWs.ToLower().Contains(".mdb")){ ws = OpenAccessDatabase(sWs); }
/* Data is in a file geodatabase */
else if (sWs.ToLower().Contains(".gdb")){ ws = OpenGeoDatabase(sWs); }
/* Assume data is a file on disk */
else{ ws = OpenRasterWorkspace(sWs); }
At this point I use helper functions for each kind of workspace. In the sample here, I will show the OpenGeoDatabase code since my sample input is for a file geodatabase.
private IWorkspace OpenGeoDatabase(string path)
{
IWorkspace ws = null;
try
{
Type factoryType =
Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
IWorkspaceFactory wsFact = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
ws = wsFact.OpenFromFile(path, 0);
}
catch (Exception exc) { }
return ws; }
Now we’re half way there. We have found the right workspace but still need to open the dataset correctly. Here I take a brute-force approach: iterating through the dataset name objects. The beauty is that I am not opening all the datasets, but simply looking for the right name— which is quick.
Note, that at this point I don’t know what kind of dataset my input is. It could be a raster dataset or a mosaic dataset (or something else). Thus, I go through the different kinds of datasets I am expecting (raster dataset and mosaic dataset in this example). I use the boolean done to quit once I’ve found the correct name.
IEnumDatasetName dsNameEnum = null;
IDatasetName dsName = null;
IName name = null;
bool done = false;
if (ws != null)
{
/* Iterate through RasterDatasetNames to check if a match exists */
dsNameEnum = ws.get_DatasetNames(esriDatasetType.esriDTRasterDataset);
dsName = dsNameEnum.Next();
while (dsName != null && done == false)
{
if (dsName.Name.ToUpper() == sDs.ToUpper())
{
name = (IName)dsName;
dataset = (IDataset)name.Open();
done = true;
}
dsName = dsNameEnum.Next();
}
/* Iterate through MosaicDatasetNames to check if a match exists */
dsNameEnum = ws.get_DatasetNames(esriDatasetType.esriDTMosaicDataset);
dsName = dsNameEnum.Next();
while (dsName != null && done == false)
{
if (dsName.Name.ToUpper() == sDs.ToUpper())
{
name = (IName)dsName;
dataset = (IDataset)name.Open();
done = true;
}
dsName = dsNameEnum.Next();
}
}
Once the dataset is opened we can do all kinds of things, including creating a layer or manipulating the dataset.
This example shows one way to open a dataset in code. There are many others.
- Accessing raster workspaces
- Accessing raster datasets
- Accessing mosaic datasets
- Accessing raster catalogs
- Accessing image services
- Accessing WCS services
- Accessing raster datasets with subdatasets (such as HDF or NITF)
Happy Coding.
Robert Berger
Saving a raster dataset to a different format
There are several advantages of doing things through code. One is that when it comes to saving raster data, you have more formats available to you that are not exposed at the user interface level. Below is a snippet of how that can be accomplished.
I start out with an opened dataset and given workspace for which to save the data. Of course I also need to know what format (e.g. TIFF) the file should be saved to. I use a boolean to return if the dataset was successfully saved or not.
public bool SaveDataset(IWorkspace ws, IRasterDataset rasDs, string dsName, string format)
{
bool success = false;
/* Main code goes here */
return success;
}
The actual code to save a raster dataset is pretty straight forward when using the ISaveAs interface. I added a small function to specify a storage definition which allows more options for the storage parameters (such as compression, etc.) but this might not be needed depending on the output format.
IRasterStorageDef rasterStorageDef = SetRasterStorageDef(); ISaveAs2 save = (ISaveAs2)rasDs; IRasterDataset newRasDs = save.SaveAsRasterDataset(dsName, ws, format, rasterStorageDef); success = newRasDs != null;
Here I have a little helper function to set the storage definition properties. Again, this is optional depending on the format.
private IRasterStorageDef SetRasterStorageDef()
{
IRasterStorageDef2 storageDef = new RasterStorageDefClass();
storageDef.CompressionType = esriRasterCompressionType.esriRasterCompressionJPEG;
storageDef.CompressionQuality = 80;
storageDef.Tiled = true;
return (IRasterStorageDef)storageDef;
}
Enjoy.
Written by: Robert Berger
Esri serves Landsat data
Working in close collaboration with DOI, Esri is pleased to announce the release of the Landsat imagery services. These image services enable fast and easy access to 30 years of Landsat imagery as part of ArcGIS Online. Esri is providing this data (more than 8 TB) on ArcGIS Online and serving it as over 20 different dynamic, multispectral, multitemporal image services that provide access to the full image information content, along with change detection capabilities. In addition, Esri has created web maps and an interactive web application that leverage these image services, providing even greater access.
Check it out at http://www.esri.com/landsat.

