Quantcast
Viewing all articles
Browse latest Browse all 2341

Commented Unassigned: Mapwingis active x 4.9 GridToImage() [25742]

I am encountering a problem with the OCX's Image class when using grid files that start out in .img format and are converted to geotiff. The grid file is displayable when opened as a Geotiff image. Further, it can be opened as a grid file and an Image object can be created successfully using GridToImage(). The Image object can even be added to the display using AddLayer(). However, I've encountered two negative behaviours: sometimes the image cannot be saved using Image.Save(), while sometimes it saves an image but cannot open it (it gets corrupted) after saving.

I also noticed that when the image is added using AddLayer(), the image also cannot be saved from the layer reference in the MapWinGIS control.

Grids files that start out as ArcInfo grids converted to Geotiff don't seem to exhibit this problem. It's very odd. Any similar problems noted?
Comments: ** Comment from web user: sleschinski **

I checked the issue (the test code is below). It worked fine, resulting tif image isn't corrupted. Our new GlobalSettings.ApplicationCallback reported a number of warning though, but they can be false positives (I'll check them). The list is below. I also added callback to report saving progress: https://mapwingis.codeplex.com/SourceControl/changeset/75313

As a pure guess an issue can be caused by missing # pragma pack(pop) directive in one of our files (sets alignment of structures). I recently fixed it, as there were inexplicable memory corruption problems. They seem to be gone after that.

@gstandard, please check if the issue is still there for you / can you reproduce it with my test code.

Here is the test code.
```
var gs = new GlobalSettings();
gs.GridProxyFormat = tkGridProxyFormat.gpfTiffProxy;

string filename = @"d:\mw\TestingScripts\ScriptData\General\Images\Formats\HFA-Erdas-Imagine-Image.img";
if (!File.Exists(filename))
{
MessageBox.Show("File wasn't found: " + filename);
return;
}

var grid = new Grid();
if (!grid.Open(filename, GridDataType.UnknownDataType, false))
{
MessageBox.Show("Failed to open grid.");
return;
}
else
{
Debug.Print("Number of bands: " + grid.NumBands);
}
var gcs = grid.GenerateColorScheme(tkGridSchemeGeneration.gsgGradient, PredefinedColorScheme.SummerMountains);
if (gcs == null)
{
grid.Close();
MessageBox.Show("Failed to generated color scheme.");
return;
}
var img = grid.OpenAsImage(gcs, tkGridProxyMode.gpmUseProxy);
if (img == null)
{
grid.Close();
MessageBox.Show("Failed to create proxy.");
return;
}

bool result = img.Save(@"d:\img_proxy.tif", true);
MessageBox.Show("Image proxy is saved: " + result.ToString());

img.Close();
grid.Close();
```

Here is the list of reported warnings (GDAL_FAILURE are internal error messages of GDAL):

GDAL FAILURE: No translation for an empty SRS to PROJ.4 format is known.
GeoProjection: OGR: Zero Length String

GDAL FAILURE: Only OGC WKT Projections supported for writing to GeoTIFF.
+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs not supported.

GDAL FAILURE: d:\mw\TestingScripts\ScriptData\General\Images\Formats\HFA-Erdas-Imagine-Image_proxy.tif, band 1: The buffer into which the data should be read is null

GDAL FAILURE: d:\mw\TestingScripts\ScriptData\General\Images\Formats\HFA-Erdas-Imagine-Image_proxy.tif, band 2: The buffer into which the data should be read is null

GDAL FAILURE: d:\mw\TestingScripts\ScriptData\General\Images\Formats\HFA-Erdas-Imagine-Image_proxy.tif, band 3: The buffer into which the data should be read is null

Image: The method or property isn't applicable to GDAL images.

GDAL WARNING: driver GTiff does not support creation option WORLDFILE


Viewing all articles
Browse latest Browse all 2341

Trending Articles