GeoImage.pm

Summary
GeoImage.pm
BE4::GeoImageDescribes a georeferenced image and enable to know its components.
Constructors
newGeoImage constructor.
_initChecks and stores file’s informations.
computing methods
computeInfoExtracts and calculates all GeoImage attributes’ values, using GDAL library (see Details).
convertBBoxNot just convert corners, but 7 points on each side, to determine reprojected bbox.
Getters - Setters
getInfoReturns all image’s geo informations in a list.
getBBoxReturn the image’s bbox as a double array [xMin, yMin, xMax, yMax], source SRS.
setImageSource
setImagePath
getXmin
getYmin
getXmax
getYmax
getXres
getYres
getName
Export methods
exportForMntConfExport a GeoImage object as a string.
exportForDebugReturns all informations about the georeferenced image.
DetailsUse the binding Perl of Gdal

BE4::GeoImage

Exporter
BE4::GeoImage

Describes a georeferenced image and enable to know its components.

Using

use BE4::GeoImage;

# GeoImage object creation
my $objGeoImage = BE4::GeoImage->new("/home/ign/DATA/XXXXX_YYYYY.tif");

Attributes

completePathstring - Complete path (/home/ign/DATA/XXXXX_YYYYY.tif)
filenamestring - Just the image name, with file extension (XXXXX_YYYYY.tif).
filepathstring - The directory which contain the image (/home/ign/DATA)
maskCompletePathstring - Complete path of associated mask, if exists (undef otherwise).
imgSrcImageSource - Image source to whom the image belong
xmindouble - Bottom left corner X coordinate.
ymindouble - Bottom left corner Y coordinate.
xmaxdouble - Top right corner X coordinate.
ymaxdouble - Top right corner Y coordinate.
xresdouble - X wise resolution (in SRS unity).
yresdouble - Y wise resolution (in SRS unity).
xcenterdouble - Center X coordinate.
ycenterdouble - Center Y coordinate.
heightinteger - Pixel height.
widthinteger - Pixel width.
Summary
Constructors
newGeoImage constructor.
_initChecks and stores file’s informations.
computing methods
computeInfoExtracts and calculates all GeoImage attributes’ values, using GDAL library (see Details).
convertBBoxNot just convert corners, but 7 points on each side, to determine reprojected bbox.
Getters - Setters
getInfoReturns all image’s geo informations in a list.
getBBoxReturn the image’s bbox as a double array [xMin, yMin, xMax, yMax], source SRS.
setImageSource
setImagePath
getXmin
getYmin
getXmax
getYmax
getXres
getYres
getName
Export methods
exportForMntConfExport a GeoImage object as a string.
exportForDebugReturns all informations about the georeferenced image.
DetailsUse the binding Perl of Gdal

Constructors

new

sub new

GeoImage constructor.  Bless an instance.

Parameters (list)

completePathstring - Complete path to the image file.

See also

_init

_init

sub _init

Checks and stores file’s informations.

Search a potential associated data mask : A file with the same base name but the extension .msk.

Parameters (list)

completePathstring - Complete path to the image file.

computing methods

computeInfo

sub computeInfo

Extracts and calculates all GeoImage attributes’ values, using GDAL library (see Details).

Image parameters are checked (sample per pixel, bits per sample...) and returned by the function.  ImageSource can verify if all images own same components and the compatibility with be4’s configuration.

Returns a list : (bitspersample,photometric,sampleformat,samplesperpixel), an empty list if error.

convertBBox

sub convertBBox

Not just convert corners, but 7 points on each side, to determine reprojected bbox.  Use OSR library.

Parameters (list)

ct<Geo::OSR::CoordinateTransformation> - To convert bbox.  Can be undefined (no reprojection).

Returns the onverted (according to the given CoordinateTransformation) image bbox as a double array [xMin, yMin, xMax, yMax], [0,0,0,0] if error.

Getters - Setters

getInfo

sub getInfo

Returns all image’s geo informations in a list.

Example

# GeoImage information getter
my (
    $filename,
    $filepath,
    $xmin,
    $ymax,
    $xmax,
    $ymin,
    $xres,
    $yres,
    $xcenter,
    $ycenter,
    $height,
    $width
) = $objGeoImage->getInfo();

getBBox

sub getBBox

Return the image’s bbox as a double array [xMin, yMin, xMax, yMax], source SRS.

setImageSource

sub setImageSource

setImagePath

sub setImagePath

getXmin

sub getXmin

getYmin

sub getYmin

getXmax

sub getXmax

getYmax

sub getYmax

getXres

sub getXres

getYres

sub getYres

getName

sub getName

Export methods

exportForMntConf

sub exportForMntConf

Export a GeoImage object as a string.  Output is formated to be used in Commands::mergeNtiff configuration.

Example

IMG completePath xmin ymax xmax ymin xres yres
MSK maskCompletePath

Parameter

useMasksboolean - Specify if we want to export mask (if present).  TRUE by default.

exportForDebug

sub exportForDebug

Returns all informations about the georeferenced image.  Useful for debug.

Example

Details

Use the binding Perl of Gdal

Sample with gdalinfo

GDAL 1.7.2, released 2010/04/23

~$ gdalinfo  image.png

Driver: PNG/Portable Network Graphics
Files: image.png
Size is 316, 261
Coordinate System is `'
Metadata:
Software=Shutter
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  261.0)
Upper Right (  316.0,    0.0)
Lower Right (  316.0,  261.0)
Center      (  158.0,  130.5)
Band 1 Block=316x1 Type=Byte, ColorInterp=Red
Band 2 Block=316x1 Type=Byte, ColorInterp=Green
Band 3 Block=316x1 Type=Byte, ColorInterp=Blue


~$ gdalinfo  image.tif
(...)
Metadata:
TIFFTAG_IMAGEDESCRIPTION=
TIFFTAG_SOFTWARE=Adobe Photoshop CS2 Windows
TIFFTAG_DATETIME=2007:03:15 11:17:17
TIFFTAG_XRESOLUTION=600
TIFFTAG_YRESOLUTION=600
TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
Image Structure Metadata:
INTERLEAVE=PIXEL
(...)
Upper Left  (  440720.000, 3751320.000) (117d38'28.21"W, 33d54'8.47"N)
Lower Left  (  440720.000, 3720600.000) (117d38'20.79"W, 33d37'31.04"N)
Upper Right (  471440.000, 3751320.000) (117d18'32.07"W, 33d54'13.08"N)
Lower Right (  471440.000, 3720600.000) (117d18'28.50"W, 33d37'35.61"N)
Center      (  456080.000, 3735960.000) (117d28'27.39"W, 33d45'52.46"N)

~$ gdalinfo image.tif

Driver: GTiff/GeoTIFF
Files: image.tif
     image.tfw
Size is 5000, 5000
Coordinate System is `'
Origin = (937500.000000000000000,6541000.000000000000000)
Pixel Size = (0.100000000000000,-0.100000000000000)
Metadata:
TIFFTAG_XRESOLUTION=100
TIFFTAG_YRESOLUTION=100
TIFFTAG_RESOLUTIONUNIT=3 (pixels/cm)
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (  937500.000, 6541000.000)
Lower Left  (  937500.000, 6540500.000)
Upper Right (  938000.000, 6541000.000)
Lower Right (  938000.000, 6540500.000)
Center      (  937750.000, 6540750.000)
Band 1 Block=5000x1 Type=Byte, ColorInterp=Red
Band 2 Block=5000x1 Type=Byte, ColorInterp=Green
Band 3 Block=5000x1 Type=Byte, ColorInterp=Blue
sub new
GeoImage constructor.
sub _init
Checks and stores file’s informations.
sub computeInfo
Extracts and calculates all GeoImage attributes’ values, using GDAL library (see Details).
Use the binding Perl of Gdal
sub convertBBox
Not just convert corners, but 7 points on each side, to determine reprojected bbox.
sub getInfo
Returns all image’s geo informations in a list.
sub getBBox
Return the image’s bbox as a double array [xMin, yMin, xMax, yMax], source SRS.
sub setImageSource
sub setImagePath
sub getXmin
sub getYmin
sub getXmax
sub getYmax
sub getXres
sub getYres
sub getName
sub exportForMntConf
Export a GeoImage object as a string.
sub exportForDebug
Returns all informations about the georeferenced image.
Define a data source, with georeferenced image directory.
sub mergeNtiff
Use the ‘MergeNtiff’ bash function.
Close