Image::GeoTIFF::Tiled::Shape
use Image::GeoTIFF::Tiled; # Initiate an instance via a class factory method, importing a pre-existing shape object: use Geo::ShapeFile; my $shp_shape = ... # A Geo::ShapeFile::Shape retrieved from Geo::ShapeFile methods my $shape = Image::GeoTIFF::Tiled::Shape->load_shape( $tiff, $shp_shape, $proj ); # OR Create your own: my $shape = Image::GeoTIFF::Tiled::Shape->new({ x_min => ..., y_min => ..., x_max => ..., y_max => ... }); $shape->add_point($x,$y) for ...; $shape->finish_loading; # Initiate the TIFF image object my $t = Image::GeoTIFF::Tiled->new( $tiff ); # Get in iterator for the pixels in the shape my $iter = $t->get_iterator( $shape );
This class is meant to be used in conjuction with Image::GeoTIFF::Tiled in order to easily iterate over image pixels contained in an arbitrary shape. It does so by linking Image::GeoTIFF::Tiled::ShapePart's, which are essentially lines between two points, with all intermediate points along integer y-values interpolated.
Objects should be instantiated via the load_shape method for pre-defined shape-like objects (Geo::ShapeFile::Shape being an example). Otherwise they must be instantiated with a boundary, and points should be added sequentially.
load_shape
Other than constructing a useful data structure for getting an iterator, there isn't any other stated purpose for this class.
All coordinates must be in pixels.
where %boundary has the x_min, y_min, x_max, and y_max keys filled or @boundary has them in that order. Pixel coordinates required. Without defining a boundary the constructor throws an exception.
Loads a pre-defined shape object defined by an external class. Currently only loads Geo::ShapeFile::Shape objects.
Geo::Proj4 and Image::GeoTIFF::Tiled objects must be pre-loaded into the class before calling this method, unless the shape is already projected, in which case omit last argument.
Boundary values.
Returns the list of (x_min, y_min, x_max, y_max).
Returns a list of four two-element arrayref's containing the upper left, upper right, lower right, and lower left corner coordinates, in that order.
Returns the number of Image::GeoTIFF::Tiled::ShapePart's in this shape.
Returns the ith Image::GeoTIFF::Tiled::ShapePart in this shape.
Returns a 2D array reference of [ start, end ] points corresponding to each part of the shape.
Adds the ($x,$y) point to this shape. Only used for making custom shapes.
Resets internal points metadata. Only used for making custom shapes, after a series of connecting points are made concentric ("parts" in ShapeFile parlance).
Sorts the internal parts array on the upper point latitude (called by finish_loading).
Call when done making a custom shape.
Returns a reference to a sorted array containing all x-pixel values along the integer y latitude. This method is used to determine if a given pixel lies inside the shape by implementing a ray-casting algorithm using a state machine (either outside or inside).
Repeated values indicate a local horizontal vertex.
Geo::Proj4, Image::GeoTIFF::Tiled, Image::GeoTIFF::Tiled::Iterator, Image::GeoTIFF::Tiled::ShapePart, Geo::ShapeFile
Copyright 2010 Blake Willmarth.
This program is free software; you can redistribute it and/or modify it under the terms of either:
the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or
the Artistic License version 2.0.
To install Image::GeoTIFF::Tiled, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Image::GeoTIFF::Tiled
CPAN shell
perl -MCPAN -e shell install Image::GeoTIFF::Tiled
For more information on module installation, please visit the detailed CPAN module installation guide.