Jesus Loves GRASS

Technical blog about GRASS/GIS,open source geoinformatics and MAPSERVER.

Friday, August 29, 2008

gdalinfo 1.4.2 versus gdalinfo 1.5.2

While processing some gdalinfo string-to-array in PHP I noticed that the output of gdalinfo is different from 1.4 to 1.5 and therefore my code broke in a new machine.
Gdal 1.4.2:
Driver: GTiff/GeoTIFF
Size is 35, 72
Coordinate System is `'
Origin = (-72000.000000000000000,
643700.000000000000000)
Pixel Size = (9422.857142857143117,-9565.277777777777374)
Corner Coordinates:
Upper Left ( -72000.000, 643700.000)
Lower Left ( -72000.000, -45000.000)
Upper Right ( 257800.000, 643700.000)
Lower Right ( 257800.000, -45000.000)
Center ( 92900.000, 299350.000)
Band 1 Block=35x58 Type=Float32, ColorInterp=Gray
Band 2 Block=35x58 Type=Float32, ColorInterp=Undefined
Band 3 Block=35x58 Type=Float32, ColorInterp=Undefined

Gdal 1.5.2
Driver: GTiff/GeoTIFF
Files: geotiff_data2087566292
Size is 35, 72
Coordinate System is `'
Origin = (-72000.000000000000000,643700.000000000000000)
Pixel Size = (9422.857142857143117,-9565.277777777777374)
Image Structure Metadata:
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( -72000.000, 643700.000)
Lower Left ( -72000.000, -45000.000)
Upper Right ( 257800.000, 643700.000)
Lower Right ( 257800.000, -45000.000)
Center ( 92900.000, 299350.000)
Band 1 Block=35x58 Type=Float32, ColorInterp=Gray
Band 2 Block=35x58 Type=Float32, ColorInterp=Undefined
Band 3 Block=35x58 Type=Float32, ColorInterp=Undefined

The new version includes:
Image Structure Metadata:
INTERLEAVE=BAND

and the name of the file that was read
Files: geotiff_data2087566292

Labels: , , ,

Tuesday, February 26, 2008

$oMap->setExtent problems and general data gathering

I made some PHP programming/MapScript for rendering a GeoTiff created by an interpolation service (WPS) as a PNG. The Geotiff is stored in the server's temporary folder and all the mapserver parameters are set by PHP programing.

The fist part of the posted code gets the image info using GdalInfo and regular expressions to obtain the extent value of the image, I haven't managed to do this properly using the PHP's Exif lib....

The major problem was the SetExtent of the Map object it was always complaining that the values had some problem, the problem was that the parameters were being passed as a string, and they needed to be as double, even if they are passed as float (or int?) the SetExtent will complain

//Some code before

$FileName=/usr/local/apache2/htdocs/tmp/interpolation3454.tiff;
$CmdStr="/usr/local/bin/gdalinfo ".$FileName;
//General string for getting float numbers
$StrPattern='/[-+]?\b[0-9]*\.?[0-9]+\b/';
exec($CmdStr,$ResultArray);

//Upper left point info
$UpperLeftPoint=$ResultArray[6];
preg_match_all($StrPattern,$UpperLeftPoint,$TmpArray);
$MinX=$TmpArray[0][0];
$MaxY=$TmpArray[0][1];

//Lower right point info
$LowerRightPoint=$ResultArray[9];
preg_match_all($StrPattern,$LowerRightPoint,$TmpArray);
$MaxX=$TmpArray[0][0];
$MinY=$TmpArray[0][1];

//Passing to Map object
//double minx, double miny, double maxx, double maxy
$oMap->setExtent((double)$MinY,(double)$MinY,(double)$MaxX,(double)$MaxY);

//Same code after

Labels: , , , , , ,