[Gdal-dev] Cannot read Idrisi in QGIS-IdrisiRasterBand::GetNoDataValue () crash

Radim Blazek radim.blazek at gmail.com
Tue Sep 5 11:22:15 EDT 2006


Hi,
I have got crash both on Windows and Linux.
gdalinfo and gdal_translate work for me.
All with GDAL 1.3.2.

Radim

On 9/5/06, Ivan Lucena <ILucena at clarku.edu> wrote:
> Frank, Radim,
>
> The issue that we have with IdrisiRasterBand::GetNoDataValue was fixed a
> long time ago. What was happening is that someone found and dataset
> where instead of "flag def`n" there was a "flag def'n" in the .rdc file.
> But I think Frank himself fixed it with those "if/else" that follows:
>
> ----------
> double IdrisiRasterBand::GetNoDataValue(int *pbSuccess)
> {
> IdrisiDataset *poGDS = (IdrisiDataset *) poDS;
>
> double dfNoData;
> const char *pszFlagDefn;
>
> if (CSLFetchNameValue(poGDS->papszRDC, rdcFLAG_DEFN) != NULL)
>         pszFlagDefn = CSLFetchNameValue(poGDS->papszRDC, rdcFLAG_DEFN);
> else if (CSLFetchNameValue(poGDS->papszRDC, rdcFLAG_DEFN2) != NULL)
>         pszFlagDefn = CSLFetchNameValue(poGDS->papszRDC, rdcFLAG_DEFN2);
>
> //
> ------------------------------------------------------------------------
> -
> // If Flag_Def is not "none", value means "background" or "missing data"
> //
> ------------------------------------------------------------------------
> -
>
> if (! EQUAL(pszFlagDefn, "none"))
> {
>         dfNoData = atof_nz(CSLFetchNameValue(poGDS->papszRDC,
> rdcFLAG_VALUE));
>         *pbSuccess = TRUE;
> }
> else
> {
>         dfNoData = -9999.0;    /* this value should be ignored */
>         *pbSuccess = FALSE;
> }
>         return dfNoData;
> }
> ----------
>
> In the previous code I also misunderstood the meaning of pbSuccess so I
> think that I also made some changes after Frank's commit, I hope I've
> got it right now Frank. If the .rdc file says that there is no "Flag
> Value" the driver returns Success as FALSE and the NoData is just a
> default and presumably ignored value.
>
> Radim, I am attaching a log of some operations that I did with your
> dataset in Win32. Unfortunately I don't have a UNIX system to test it on
> now.
>
> So the question is: Why is crashing in your computer?
>
> One possibility is that Frank and I know that in the released version
> GDAL-1.3.2 in zip or tar.gz package there is a known bug in the RST
> driver related to coordinate system identification. Is it possible that
> your bug-tracker is pointing to the wrong function?
>
> I suggest you to get the latest version from CVS or even better wait a
> little bit and I will commit some fixes that I made this past weekend.
>
> Thanks for helping me identify error and improve my code.
>
> Ivan Lucena
>
> "Smart data structure and dumb code works a lot better than the other
> way around" Eric S. Raymond, The Cathedral and the Bazaar.
>
> ----------
> C:\Data\x>gdal_translate -of gtiff western_form1.rst western_form1.tif
> 0...10...20...30...40...50...60...70...80...90...Input file size is
> 3100, 2100
> 100 - done.
>
>
> C:\Data\x>gdalinfo western_form1.rst
> Driver: RST/Idrisi Raster A.1
> Size is 3100, 2100
> Coordinate System is `'
> Origin = (100.000000,744.000000)
> Pixel Size = (0.01000000,-0.01000000)
> Corner Coordinates:
> Upper Left  (     100.000,     744.000)
> Lower Left  (     100.000,     723.000)
> Upper Right (     131.000,     744.000)
> Lower Right (     131.000,     723.000)
> Center      (     115.500,     733.500)
> Band 1 Block=3100x1 Type=Byte, ColorInterp=Gray
>   Min=0.000 Max=3.000
>   NoData Value=0
>   Unit Type: classes
>   Categories:
>       0:
>       1: AREA OCUPADA
>       2: RECONOCIDA
>       3: NO RECON.
>
> C:\Data\x>gdalinfo western_form1.tif
> Driver: GTiff/GeoTIFF
> Size is 3100, 2100
> Coordinate System is `'
> Origin = (100.000000,744.000000)
> Pixel Size = (0.01000000,-0.01000000)
> Corner Coordinates:
> Upper Left  (     100.000,     744.000)
> Lower Left  (     100.000,     723.000)
> Upper Right (     131.000,     744.000)
> Lower Right (     131.000,     723.000)
> Center      (     115.500,     733.500)
> Band 1 Block=3100x2 Type=Byte, ColorInterp=Gray
>   NoData Value=0
> ----------
>
> -----Original Message-----
> From: gdal-dev-bounces at lists.maptools.org
> [mailto:gdal-dev-bounces at lists.maptools.org] On Behalf Of Frank
> Warmerdam
> Sent: Monday, September 04, 2006 2:04 PM
> To: Radim Blazek
> Cc: gdal-dev at lists.maptools.org; qgis-developer
> Subject: Re: [Gdal-dev] Cannot read Idrisi in QGIS-
> IdrisiRasterBand::GetNoDataValue () crash
>
> Radim Blazek wrote:
> > QGIS crashes when I try to open data in Idrisi format
> > (http://www.pitt.edu/~laad/vdlpsurv/western_form1_idrisi.exe)
> >
> > Backtrace:
> >
> > #0  0xb6a39ef4 in IdrisiRasterBand::GetNoDataValue ()
> >   from /usr/local/lib/libgdal.so.1
> > #1  0xb7fd2592 in QgsRasterLayer::readFile (this=0x8233bd8,
> fileName=@0x1)
> >    at qgsrasterlayer.cpp:604
> > #2  0xb7fd9f97 in QgsRasterLayer (this=0x8233bd8, path=@0x81f7584,
> >    baseName=@0xbfffdab0) at qgsrasterlayer.cpp:467
> > #3  0xb7d18d6e in QgisApp::addRasterLayer (this=0x80e1188,
> >
> > Probably we have to check first if the data source has no data value
> > defined before caling GDAL GetNoDataValue ()?
>
> Radim,
>
> I haven't looked at the dataset in question, but there was a bug at one
> point
> in the IDRISI driver related to missing nodata values.  Perhaps Ivan
> will
> try the dataset, and indicate if there is still a problem.
>
> QGIS should be able to call GetNoDataValue() safely without any sort of
> pre-test.   If it causes a crash in GDAL then it is a bug that should
> be fixed in GDAL.
>
> Best regards,
> --
> ---------------------------------------+--------------------------------
> ------
> I set the clouds in motion - turn up   | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | President OSGeo,
> http://osgeo.org
>
> _______________________________________________
> Gdal-dev mailing list
> Gdal-dev at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/gdal-dev
>



More information about the Gdal-dev mailing list