2 # @brief GDAL utility functions and a root class for raster classes.
3 # @details Geo::GDAL wraps many GDAL utility functions and is as a root class
4 # for all GDAL raster classes. A "raster" is an object, whose core is
5 # a rectagular grid of cells, called a "band" in GDAL. Each cell
6 # contains a numeric value of a specific data type.
10 #** @method ApplyVerticalShiftGrid()
12 sub ApplyVerticalShiftGrid {
15 #** @method BuildVRT()
18 for (keys %Geo::GDAL::Const::) {
20 push(@DATA_TYPES, $1), next
if /^GDT_(\w+)/;
21 push(@OPEN_FLAGS, $1), next
if /^OF_(\w+)/;
22 push(@RESAMPLING_TYPES, $1), next
if /^GRA_(\w+)/;
23 push(@RIO_RESAMPLING_TYPES, $1), next
if /^GRIORA_(\w+)/;
24 push(@NODE_TYPES, $1), next
if /^CXT_(\w+)/;
26 for my $string (@DATA_TYPES) {
27 my $int = eval
"\$Geo::GDAL::Const::GDT_$string";
28 $S2I{data_type}{$string} = $int;
29 $I2S{data_type}{$int} = $string;
31 for my $string (@OPEN_FLAGS) {
32 my $int = eval
"\$Geo::GDAL::Const::OF_$string";
33 $S2I{open_flag}{$string} = $int;
35 for my $string (@RESAMPLING_TYPES) {
36 my $int = eval
"\$Geo::GDAL::Const::GRA_$string";
37 $S2I{resampling}{$string} = $int;
38 $I2S{resampling}{$int} = $string;
40 for my $string (@RIO_RESAMPLING_TYPES) {
41 my $int = eval
"\$Geo::GDAL::Const::GRIORA_$string";
42 $S2I{rio_resampling}{$string} = $int;
43 $I2S{rio_resampling}{$int} = $string;
45 for my $string (@NODE_TYPES) {
46 my $int = eval
"\$Geo::GDAL::Const::CXT_$string";
47 $S2I{node_type}{$string} = $int;
48 $I2S{node_type}{$int} = $string;
52 $HAVE_PDL = 1 unless $@;
55 #** @method CPLBinaryToHex()
60 #** @method CPLHexToBinary()
65 #** @method ContourGenerateEx()
67 sub ContourGenerateEx {
70 #** @method CreatePansharpenedVRT()
72 sub CreatePansharpenedVRT {
75 #** @method scalar DataTypeIsComplex($DataType)
77 # @param DataType A GDAL raster cell data type (one of those listed by Geo::GDAL::DataTypes).
78 # @return true if the data type is a complex number.
80 sub DataTypeIsComplex {
81 return _DataTypeIsComplex(s2i(data_type => shift));
84 #** @method list DataTypeValueRange($DataType)
86 # @param DataType Data type (one of those listed by Geo::GDAL::DataTypes).
87 # @note Some returned values are inaccurate.
89 # @return the minimum, maximum range of the data type.
91 sub DataTypeValueRange {
94 # these values are from gdalrasterband.cpp
95 return (0,255)
if $t =~ /Byte/;
96 return (0,65535)
if $t =~/UInt16/;
97 return (-32768,32767)
if $t =~/Int16/;
98 return (0,4294967295)
if $t =~/UInt32/;
99 return (-2147483648,2147483647)
if $t =~/Int32/;
100 return (-4294967295.0,4294967295.0)
if $t =~/Float32/;
101 return (-4294967295.0,4294967295.0)
if $t =~/Float64/;
104 #** @method list DataTypes()
105 # Package subroutine.
106 # @return a list of GDAL raster cell data types. These are currently:
107 # Byte, CFloat32, CFloat64, CInt16, CInt32, Float32, Float64, Int16, Int32, UInt16, UInt32, and Unknown.
113 #** @method scalar DecToDMS($angle, $axis, $precision=2)
114 # Package subroutine.
115 # Convert decimal degrees to degrees, minutes, and seconds string
116 # @param angle A number
117 # @param axis A string specifying latitude or longitude ('Long').
119 # @return a string nndnn'nn.nn'"L where n is a number and L is either
125 #** @method scalar DecToPackedDMS($dec)
126 # Package subroutine.
127 # @param dec Decimal degrees
128 # @return packed DMS, i.e., a number DDDMMMSSS.SS
133 #** @method DontUseExceptions()
134 # Package subroutine.
135 # Do not use the Perl exception mechanism for GDAL messages. Instead
136 # the messages are printed to standard error.
138 sub DontUseExceptions {
141 #** @method Geo::GDAL::Driver Driver($Name)
142 # Package subroutine.
143 # Access a format driver.
144 # @param Name The short name of the driver. One of
145 # Geo::GDAL::DriverNames or Geo::OGR::DriverNames.
146 # @note This subroutine is imported into the main namespace if Geo::GDAL
147 # is used with qw/:all/.
148 # @return a Geo::GDAL::Driver object.
151 return 'Geo::GDAL::Driver' unless @_;
153 my $driver = GetDriver($name);
154 error("Driver \"$name\" not found. Is it built in? Check with Geo::GDAL::Drivers or Geo::OGR::Drivers.")
159 #** @method list DriverNames()
160 # Package subroutine.
161 # Available raster format drivers.
163 # perl -MGeo::GDAL -e '@d=Geo::GDAL::DriverNames;print "@d\n"'
165 # @note Use Geo::OGR::DriverNames for vector drivers.
166 # @return a list of the short names of all available GDAL raster drivers.
171 #** @method list Drivers()
172 # Package subroutine.
173 # @note Use Geo::OGR::Drivers for vector drivers.
174 # @return a list of all available GDAL raster drivers.
178 for my $i (0..GetDriverCount()-1) {
179 my $driver = GetDriver($i);
180 push @drivers, $driver
if $driver->TestCapability(
'RASTER');
185 #** @method EscapeString()
190 #** @method scalar FindFile($basename)
191 # Package subroutine.
192 # Search for GDAL support files.
197 # $a = Geo::GDAL::FindFile('pcs.csv');
198 # print STDERR "$a\n";
200 # Prints (for example):
202 # c:\msys\1.0\local\share\gdal\pcs.csv
205 # @param basename The name of the file to search for. For example
207 # @return the path to the searched file or undef.
217 #** @method FinderClean()
218 # Package subroutine.
219 # Clear the set of support file search paths.
224 #** @method GDALMultiDimInfo()
226 sub GDALMultiDimInfo {
229 #** @method GEDTC_COMPOUND()
234 #** @method GEDTC_NUMERIC()
239 #** @method GEDTC_STRING()
244 #** @method GEDTST_JSON()
249 #** @method GEDTST_NONE()
254 #** @method GOA2GetAccessToken()
256 sub GOA2GetAccessToken {
259 #** @method GOA2GetAuthorizationURL()
261 sub GOA2GetAuthorizationURL {
264 #** @method GOA2GetRefreshToken()
266 sub GOA2GetRefreshToken {
269 #** @method GVM_Diagonal()
274 #** @method GVM_Edge()
279 #** @method GVM_Max()
284 #** @method GVM_Min()
289 #** @method GVOT_MIN_TARGET_HEIGHT_FROM_DEM()
291 sub GVOT_MIN_TARGET_HEIGHT_FROM_DEM {
294 #** @method GVOT_MIN_TARGET_HEIGHT_FROM_GROUND()
296 sub GVOT_MIN_TARGET_HEIGHT_FROM_GROUND {
297 # keeper maintains child -> parent relationships
298 # child is kept as a key, i.e., string not the real object
299 # parent is kept as the value, i.e., a real object
300 # a child may have only one parent!
301 # call these as Geo::GDAL::*
306 #** @method GVOT_NORMAL()
311 #** @method GetActualURL()
316 #** @method scalar GetCacheMax()
317 # Package subroutine.
318 # @return maximum amount of memory (as bytes) for caching within GDAL.
323 #** @method scalar GetCacheUsed()
324 # Package subroutine.
325 # @return the amount of memory currently used for caching within GDAL.
330 #** @method scalar GetConfigOption($key)
331 # Package subroutine.
332 # @param key A GDAL config option. Consult <a
333 # href="https://trac.osgeo.org/gdal/wiki/ConfigOptions">the GDAL
334 # documentation</a> for available options and their use.
335 # @return the value of the GDAL config option.
337 sub GetConfigOption {
340 #** @method scalar GetDataTypeSize($DataType)
341 # Package subroutine.
342 # @param DataType A GDAL raster cell data type (one of those listed by Geo::GDAL::DataTypes).
343 # @return the size as the number of bits.
345 sub GetDataTypeSize {
346 return _GetDataTypeSize(s2i(data_type => shift, 1));
349 #** @method GetErrorCounter()
351 sub GetErrorCounter {
354 #** @method GetFileMetadata()
356 sub GetFileMetadata {
359 #** @method GetFileSystemOptions()
361 sub GetFileSystemOptions {
364 #** @method GetFileSystemsPrefixes()
366 sub GetFileSystemsPrefixes {
369 #** @method GetJPEG2000StructureAsString()
371 sub GetJPEG2000StructureAsString {
374 #** @method GetSignedURL()
379 #** @method GetThreadLocalConfigOption()
381 sub GetThreadLocalConfigOption {
384 #** @method Geo::GDAL::Driver IdentifyDriver($path, $siblings)
385 # Package subroutine.
386 # @param path a dataset path.
387 # @param siblings [optional] A list of names of files that belong to the data format.
388 # @return a Geo::GDAL::Driver.
393 #** @method IdentifyDriverEx()
395 sub IdentifyDriverEx {
398 #** @method MkdirRecursive()
403 #** @method NetworkStatsGetAsSerializedJSON()
405 sub NetworkStatsGetAsSerializedJSON {
408 #** @method NetworkStatsReset()
410 sub NetworkStatsReset {
413 #** @method Geo::GDAL::Dataset Open(%params)
414 # Package subroutine.
416 # An example, which opens an existing raster dataset for editing:
418 # use Geo::GDAL qw/:all/;
419 # $ds = Open(Name => 'existing.tiff', Access => 'Update');
421 # @param params Named parameters:
422 # - \a Name Dataset string (typically a filename). Default is '.'.
423 # - \a Access Access type, either 'ReadOnly' or 'Update'. Default is 'ReadOnly'.
424 # - \a Type Dataset type, either 'Raster', 'Vector', or 'Any'. Default is 'Any'.
425 # - \a Options A hash of GDAL open options passed to candidate drivers. Default is {}.
426 # - \a Files A list of names of files that are auxiliary to the main file. Default is [].
428 # @note This subroutine is imported into the main namespace if Geo::GDAL
429 # is use'd with qw/:all/.
431 # @note Some datasets / dataset strings do not explicitly imply the
432 # dataset type (for example a PostGIS database). If the type is not
433 # specified in such a case the returned dataset may be of either type.
435 # @return a new Geo::GDAL::Dataset object if success.
438 my $p = named_parameters(\@_, Name =>
'.', Access =>
'ReadOnly', Type =>
'Any', Options => {}, Files => []);
440 my %o = (READONLY => 1, UPDATE => 1);
441 error(1, $p->{access}, \%o) unless $o{uc($p->{access})};
442 push @flags, uc($p->{access});
443 %o = (RASTER => 1, VECTOR => 1, ANY => 1);
444 error(1, $p->{type}, \%o) unless $o{uc($p->{type})};
445 push @flags, uc($p->{type}) unless uc($p->{type}) eq
'ANY';
446 my $dataset = OpenEx(Name => $p->{name}, Flags => \@flags, Options => $p->{options}, Files => $p->{files});
448 my $t =
"Failed to open $p->{name}.";
449 $t .=
" Is it a ".lc($p->{type}).
" dataset?" unless uc($p->{type}) eq
'ANY';
455 #** @method Geo::GDAL::Dataset OpenEx(%params)
456 # Package subroutine.
457 # The generic dataset open method, used internally by all Open and OpenShared methods.
458 # @param params Named parameters:
459 # - \a Name The name of the data set or source to open. (Default is '.')
460 # - \a Flags A list of access mode flags. Available flags are listed by Geo::GDAL::OpenFlags(). (Default is [])
461 # - \a Drivers A list of short names of drivers that may be used. Empty list means all. (Default is [])
462 # - \a Options A hash of GDAL open options passed to candidate drivers. (Default is {})
463 # - \a Files A list of names of files that are auxiliary to the main file. (Default is [])
467 # $ds = Geo::GDAL::OpenEx(Name => 'existing.tiff', Flags => [qw/RASTER UPDATE/]);
469 # @return a new Geo::GDAL::Dataset object.
472 my $p = named_parameters(\@_, Name =>
'.', Flags => [], Drivers => [], Options => {}, Files => []);
476 $p = {name => $name, flags => \@flags, drivers => [], options => {}, files => []};
480 for my $flag (@{$p->{flags}}) {
481 $f |= s2i(open_flag => $flag);
485 return _OpenEx($p->{name}, $p->{flags}, $p->{drivers}, $p->{options}, $p->{files});
488 #** @method list OpenFlags()
489 # Package subroutine.
490 # @return a list of GDAL data set open modes. These are currently:
491 # ALL, GNM, MULTIDIM_RASTER, RASTER, READONLY, SHARED, UPDATE, VECTOR, and VERBOSE_ERROR.
497 #** @method scalar PackCharacter($DataType)
498 # Package subroutine.
499 # Get the character that is needed for Perl's pack and unpack when
500 # they are used with Geo::GDAL::Band::ReadRaster and
501 # Geo::GDAL::Band::WriteRaster. Note that Geo::GDAL::Band::ReadTile
502 # and Geo::GDAL::Band::WriteTile have simpler interfaces that do not
503 # require pack and unpack.
504 # @param DataType A GDAL raster cell data type, typically from $band->DataType.
505 # @return a character which can be used in Perl's pack and unpack.
509 $t = i2s(data_type => $t);
510 s2i(data_type => $t); # test
511 my $is_big_endian = unpack(
"h*", pack(
"s", 1)) =~ /01/; # from Programming Perl
512 return 'C' if $t =~ /^Byte$/;
513 return ($is_big_endian ?
'n':
'v')
if $t =~ /^UInt16$/;
514 return 's' if $t =~ /^Int16$/;
515 return ($is_big_endian ?
'N' :
'V')
if $t =~ /^UInt32$/;
516 return 'l' if $t =~ /^Int32$/;
517 return 'f' if $t =~ /^Float32$/;
518 return 'd' if $t =~ /^Float64$/;
521 #** @method scalar PackedDMSToDec($packed)
522 # Package subroutine.
523 # @param packed DMS as a number DDDMMMSSS.SS
524 # @return decimal degrees
529 #** @method PopFinderLocation()
530 # Package subroutine.
531 # Remove the latest addition from the set of support file search
532 # paths. Note that calling this subroutine may remove paths GDAL put
535 sub PopFinderLocation {
538 #** @method PushFinderLocation($path)
539 # Package subroutine.
540 # Add a path to the set of paths from where GDAL support files are
541 # sought. Note that GDAL puts initially into the finder the current
542 # directory and value of GDAL_DATA environment variable (if it
543 # exists), installation directory (prepended with '/share/gdal' or
544 # '/Resources/gdal'), or '/usr/local/share/gdal'. It is usually only
545 # needed to add paths to the finder if using an alternate set of data
546 # files or a non-installed GDAL is used (as in testing).
548 sub PushFinderLocation {
551 #** @method list RIOResamplingTypes()
552 # Package subroutine.
553 # @return a list of GDAL raster IO resampling methods. These are currently:
554 # Average, Bilinear, Cubic, CubicSpline, Gauss, Lanczos, Mode, NearestNeighbour, and RMS.
556 sub RIOResamplingTypes {
557 return @RIO_RESAMPLING_TYPES;
560 #** @method list ResamplingTypes()
561 # Package subroutine.
562 # @return a list of GDAL resampling methods. These are currently:
563 # Average, Bilinear, Cubic, CubicSpline, Lanczos, Max, Med, Min, Mode, NearestNeighbour, Q1, Q3, RMS, and Sum.
565 sub ResamplingTypes {
566 return @RESAMPLING_TYPES;
569 #** @method RmdirRecursive()
574 #** @method SetCacheMax($Bytes)
575 # Package subroutine.
576 # @param Bytes New maximum amount of memory for caching within GDAL.
581 #** @method SetConfigOption($key, $value)
582 # Package subroutine.
583 # @param key A GDAL config option. Consult <a
584 # href="https://trac.osgeo.org/gdal/wiki/ConfigOptions">the GDAL
585 # documentation</a> for available options and their use.
586 # @param value A value for the option, typically 'YES', 'NO',
587 # undef, path, numeric value, or a filename.
589 sub SetConfigOption {
592 #** @method SetCurrentErrorHandlerCatchDebug()
594 sub SetCurrentErrorHandlerCatchDebug {
597 #** @method SetFileMetadata()
599 sub SetFileMetadata {
602 #** @method SetThreadLocalConfigOption()
604 sub SetThreadLocalConfigOption {
607 #** @method UnlinkBatch()
612 #** @method UseExceptions()
613 # Package subroutine.
614 # Use the Perl exception mechanism for GDAL messages (failures are
615 # confessed and warnings are warned) and collect the messages
616 # into \@Geo::GDAL::error. This is the default.
621 #** @method VSICurlClearCache()
623 sub VSICurlClearCache {
626 #** @method VSICurlPartialClearCache()
628 sub VSICurlPartialClearCache {
631 #** @method VSIErrorReset()
636 #** @method VSIFEofL()
641 #** @method VSIFFlushL()
646 #** @method VSIFOpenExL()
651 #** @method VSIGetLastErrorMsg()
653 sub VSIGetLastErrorMsg {
656 #** @method VSIGetLastErrorNo()
658 sub VSIGetLastErrorNo {
661 #** @method scalar VersionInfo($request = 'VERSION_NUM')
662 # Package subroutine.
663 # @param request A string specifying the request. Currently either
664 # "VERSION_NUM", "RELEASE_DATE", "RELEASE_NAME", or
665 # "--version". Default is "VERSION_NUM".
666 # @return Requested information.
671 #** @method ViewshedGenerate()
673 sub ViewshedGenerate {
676 #** @method scalar errstr()
677 # Package subroutine.
678 # Clear the error stack and return all generated GDAL error messages in one (possibly multiline) string.
679 # @return the chomped error stack joined with newlines.
685 return join(
"\n", @stack);
687 # usage: named_parameters(\@_, key value list of default parameters);
688 # returns parameters in a hash with low-case-without-_ keys
691 #** @method wrapper_GDALMultiDimTranslateDestName()
693 sub wrapper_GDALMultiDimTranslateDestName {
696 #** @class Geo::GDAL::AsyncReader
697 # @brief Enable asynchronous requests.
698 # @details This class is not yet documented nor tested in the GDAL Perl wrappers
699 # @todo Test and document.
701 package Geo::GDAL::AsyncReader;
705 #** @method GetNextUpdatedRegion()
707 sub GetNextUpdatedRegion {
710 #** @method LockBuffer()
715 #** @method UnlockBuffer()
720 #** @class Geo::GDAL::Attribute
722 package Geo::GDAL::Attribute;
726 #** @method GetDataType()
731 #** @method GetDimensionCount()
733 sub GetDimensionCount {
736 #** @method GetFullName()
741 #** @method GetName()
746 #** @method GetTotalElementsCount()
748 sub GetTotalElementsCount {
751 #** @method ReadAsDouble()
756 #** @method ReadAsInt()
761 #** @method ReadAsString()
766 #** @method ReadAsStringArray()
768 sub ReadAsStringArray {
771 #** @method WriteDouble()
776 #** @method WriteInt()
781 #** @method WriteString()
786 #** @method WriteStringArray()
788 sub WriteStringArray {
791 #** @class Geo::GDAL::Band
792 # @brief A raster band.
795 package Geo::GDAL::Band;
801 # scalar (access as $band->{XSize})
806 # scalar (access as $band->{YSize})
809 #** @method AdviseRead()
814 #** @method AsMDArray()
819 #** @method Geo::GDAL::RasterAttributeTable AttributeTable($AttributeTable)
821 # @param AttributeTable [optional] A Geo::GDAL::RasterAttributeTable object.
822 # @return a new Geo::GDAL::RasterAttributeTable object, whose data is
823 # contained within the band.
827 SetDefaultRAT($self, $_[0])
if @_ and defined $_[0];
828 return unless defined wantarray;
829 my $r = GetDefaultRAT($self);
830 keep($r, $self)
if $r;
833 #** @method list BlockSize()
836 # @return The size of a preferred i/o raster block size as a list
842 #** @method list CategoryNames(@names)
844 # @param names [optional]
849 SetRasterCategoryNames($self, \@_)
if @_;
850 return unless defined wantarray;
851 my $n = GetRasterCategoryNames($self);
855 #** @method scalar Checksum($xoff = 0, $yoff = 0, $xsize = undef, $ysize = undef)
857 # Computes a checksum from the raster or a part of it.
862 # @return the checksum.
867 #** @method hashref ClassCounts($classifier, $progress = undef, $progress_data = undef)
869 # Compute the counts of cell values or number of cell values in ranges.
870 # @note Classifier is required only for float bands.
871 # @note NoData values are counted similar to other values when
872 # classifier is not defined for integer rasters.
874 # @param classifier Anonymous array of format [ $comparison,
875 # $classifier ], where $comparison is a string '<', '<=', '>', or '>='
876 # and $classifier is an anonymous array of format [ $value,
877 # $value|$classifier, $value|$classifier ], where $value is a numeric
878 # value against which the reclassified value is compared to. If the
879 # comparison returns true, then the second $value or $classifier is
880 # applied, and if not then the third $value or $classifier.
882 # In the example below, the line is divided into ranges
883 # [-inf..3), [3..5), and [5..inf], i.e., three ranges with class
884 # indexes 0, 1, and 2. Note that the indexes are used as keys for
885 # class counts and not the class values (here 1.0, 2.0, and 3.0),
886 # which are used in Geo::GDAL::Band::Reclassify.
888 # $classifier = [ '<', [5.0, [3.0, 1.0, 2.0], 3.0] ];
889 # # Howto create this $classifier from @class_boundaries:
890 # my $classifier = ['<='];
891 # my $tree = [$class_boundaries[0], 0, 1];
892 # for my $i (1 .. $#class_boundaries) {
893 # $tree = [$class_boundaries[$i], [@$tree], $i+1];
895 # push @$classifier, $tree;
897 # @return a reference to an anonymous hash, which contains the class
898 # values (indexes) as keys and the number of cells with that value or
899 # in that range as values. If the subroutine is user terminated an
905 #** @method scalar ColorInterpretation($color_interpretation)
907 # @note a.k.a. GetRasterColorInterpretation and GetColorInterpretation
908 # (get only and returns an integer), SetRasterColorInterpretation and
909 # SetColorInterpretation (set only and requires an integer)
910 # @param color_interpretation [optional] new color interpretation, one
911 # of Geo::GDAL::Band::ColorInterpretations.
912 # @return The color interpretation of this band. One of Geo::GDAL::Band::ColorInterpretations.
914 sub ColorInterpretation {
917 $ci = s2i(color_interpretation => $ci);
918 SetRasterColorInterpretation($self, $ci);
920 return unless defined wantarray;
921 i2s(color_interpretation => GetRasterColorInterpretation($self));
924 #** @method ColorInterpretations()
925 # Package subroutine.
926 # @return a list of types of color interpretation for raster
927 # bands. These are currently:
928 # AlphaBand, BlackBand, BlueBand, CyanBand, GrayIndex, GreenBand, HueBand, LightnessBand, MagentaBand, PaletteIndex, RedBand, SaturationBand, Undefined, YCbCr_CbBand, YCbCr_CrBand, YCbCr_YBand, and YellowBand.
930 sub ColorInterpretations {
931 return @COLOR_INTERPRETATIONS;
934 #** @method Geo::GDAL::ColorTable ColorTable($ColorTable)
936 # Get or set the color table of this band.
937 # @param ColorTable [optional] a Geo::GDAL::ColorTable object
938 # @return A new Geo::GDAL::ColorTable object which represents the
939 # internal color table associated with this band. Returns undef this
940 # band does not have an associated color table.
944 SetRasterColorTable($self, $_[0])
if @_ and defined $_[0];
945 return unless defined wantarray;
946 GetRasterColorTable($self);
949 #** @method ComputeBandStats($samplestep = 1)
951 # @param samplestep the row increment in computing the statistics.
952 # @note Returns uncorrected sample standard deviation.
954 # See also Geo::GDAL::Band::ComputeStatistics.
955 # @return a list (mean, stddev).
957 sub ComputeBandStats {
960 #** @method ComputeRasterMinMax($approx_ok = 0)
962 # @return arrayref MinMax = [min, max]
964 sub ComputeRasterMinMax {
967 #** @method list ComputeStatistics($approx_ok, $progress = undef, $progress_data = undef)
969 # @param approx_ok Whether it is allowed to compute the statistics
970 # based on overviews or similar.
971 # @note Returns uncorrected sample standard deviation.
973 # See also Geo::GDAL::Band::ComputeBandStats.
974 # @return a list ($min, $max, $mean, $stddev).
976 sub ComputeStatistics {
979 #** @method Geo::OGR::Layer Contours($DataSource, hashref LayerConstructor, $ContourInterval, $ContourBase, arrayref FixedLevels, $NoDataValue, $IDField, $ElevField, coderef Progress, $ProgressData)
981 # Generate contours for this raster band. This method can also be used with named parameters.
982 # @note This method is a wrapper for ContourGenerate.
987 # $dem = Geo::GDAL::Open('dem.gtiff');
988 # $contours = $dem->Band->Contours(ContourInterval => 10, ElevField => 'z');
989 # $n = $contours->GetFeatureCount;
992 # @param DataSource a Geo::OGR::DataSource object, default is a Memory data source
993 # @param LayerConstructor data for Geo::OGR::DataSource::CreateLayer, default is {Name => 'contours'}
994 # @param ContourInterval default is 100
995 # @param ContourBase default is 0
996 # @param FixedLevels a reference to a list of fixed contour levels, default is []
997 # @param NoDataValue default is undef
998 # @param IDField default is '', i.e., no field (the field is created if this is given)
999 # @param ElevField default is '', i.e., no field (the field is created if this is given)
1000 # @param progress [optional] a reference to a subroutine, which will
1001 # be called with parameters (number progress, string msg, progress_data)
1002 # @param progress_data [optional]
1007 my $p = named_parameters(\@_,
1008 DataSource => undef,
1009 LayerConstructor => {Name =>
'contours'},
1010 ContourInterval => 100,
1013 NoDataValue => undef,
1017 ProgressData => undef);
1019 $p->{layerconstructor}->{Schema}
1020 $p->{layerconstructor}->{Schema}{Fields}
1022 unless ($p->{idfield} =~ /^[+-]?\d+$/ or $fields{$p->{idfield}}) {
1023 push @{$p->{layerconstructor}->{Schema}{Fields}}, {Name => $p->{idfield}, Type =>
'Integer'};
1025 unless ($p->{elevfield} =~ /^[+-]?\d+$/ or $fields{$p->{elevfield}}) {
1026 my $type = $self->DataType() =~ /Float/ ?
'Real' :
'Integer';
1027 push @{$p->{layerconstructor}->{Schema}{Fields}}, {Name => $p->{elevfield}, Type => $type};
1029 my $layer = $p->{datasource}->CreateLayer($p->{layerconstructor});
1030 my $schema = $layer->GetLayerDefn;
1031 for (
'idfield',
'elevfield') {
1032 $p->{$_} = $schema->GetFieldIndex($p->{$_}) unless $p->{$_} =~ /^[+-]?\d+$/;
1034 $p->{progressdata} = 1
if $p->{progress} and not defined $p->{progressdata};
1035 ContourGenerate($self, $p->{contourinterval}, $p->{contourbase}, $p->{fixedlevels},
1036 $p->{nodatavalue}, $layer, $p->{idfield}, $p->{elevfield},
1037 $p->{progress}, $p->{progressdata});
1041 #** @method CreateMaskBand(@flags)
1043 # @note May invalidate any previous mask band obtained with Geo::GDAL::Band::GetMaskBand.
1045 # @param flags one or more mask flags. The flags are Geo::GDAL::Band::MaskFlags.
1047 sub CreateMaskBand {
1050 if (@_ and $_[0] =~ /^\d$/) {
1054 carp
"Unknown mask flag: '$flag'." unless $MASK_FLAGS{$flag};
1055 $f |= $MASK_FLAGS{$flag};
1058 $self->_CreateMaskBand($f);
1061 #** @method scalar DataType()
1063 # @return The data type of this band. One of Geo::GDAL::DataTypes.
1067 return i2s(data_type => $self->{DataType});
1070 #** @method Geo::GDAL::Dataset Dataset()
1072 # @return The dataset which this band belongs to.
1079 #** @method scalar DeleteNoDataValue()
1082 sub DeleteNoDataValue {
1085 #** @method Geo::GDAL::Band Distance(%params)
1087 # Compute distances to specific cells of this raster.
1088 # @param params Named parameters:
1089 # - \a Distance A raster band, into which the distances are computed. If not given, a not given, a new in-memory raster band is created and returned. The data type of the raster can be given in the options.
1090 # - \a Options Hash of options. Options are:
1091 # - \a Values A list of cell values in this band to measure the distance from. If this option is not provided, the distance will be computed to non-zero pixel values. Currently pixel values are internally processed as integers.
1092 # - \a DistUnits=PIXEL|GEO Indicates whether distances will be computed in cells or in georeferenced units. The default is pixel units. This also determines the interpretation of MaxDist.
1093 # - \a MaxDist=n The maximum distance to search. Distances greater than this value will not be computed. Instead output cells will be set to a NoData value.
1094 # - \a NoData=n The NoData value to use on the distance band for cells that are beyond MaxDist. If not provided, the distance band will be queried for a NoData value. If one is not found, 65535 will be used (255 if the type is Byte).
1095 # - \a Use_Input_NoData=YES|NO If this option is set, the NoData value of this band will be respected. Leaving NoData cells in the input as NoData pixels in the distance raster.
1096 # - \a Fixed_Buf_Val=n If this option is set, all cells within the MaxDist threshold are set to this value instead of the distance value.
1097 # - \a DataType The data type for the result if it is not given.
1098 # - \a Progress Progress function.
1099 # - \a ProgressData Additional parameter for the progress function.
1101 # @note This GDAL function behind this API is called GDALComputeProximity.
1103 # @return The distance raster.
1107 my $p = named_parameters(\@_, Distance => undef, Options => undef, Progress => undef, ProgressData => undef);
1108 for my $key (keys %{$p->{options}}) {
1109 $p->{options}{uc($key)} = $p->{options}{$key};
1112 unless ($p->{distance}) {
1113 my ($w, $h) = $self->Size;
1114 $p->{distance} =
Geo::GDAL::Driver(
'MEM')->
Create(Name =>
'distance', Width => $w, Height => $h, Type => $p->{options}{TYPE})->Band;
1116 Geo::GDAL::ComputeProximity($self, $p->{distance}, $p->{options}, $p->{progress}, $p->{progressdata});
1117 return $p->{distance};
1120 #** @method Domains()
1126 #** @method Fill($real_part, $imag_part = 0.0)
1128 # Fill the band with a constant value.
1129 # @param real_part Real component of fill value.
1130 # @param imag_part Imaginary component of fill value.
1136 #** @method FillNoData($mask, $max_search_dist, $smoothing_iterations, $options, coderef progress, $progress_data)
1138 # Interpolate values for cells in this raster. The cells to fill
1139 # should be marked in the mask band with zero.
1141 # @param mask [optional] a mask band indicating cells to be interpolated (zero valued) (default is to get it with Geo::GDAL::Band::GetMaskBand).
1142 # @param max_search_dist [optional] the maximum number of cells to
1143 # search in all directions to find values to interpolate from (default is 10).
1144 # @param smoothing_iterations [optional] the number of 3x3 smoothing filter passes to run (0 or more) (default is 0).
1145 # @param options [optional] A reference to a hash. No options have been defined so far for this algorithm (default is {}).
1146 # @param progress [optional] a reference to a subroutine, which will
1147 # be called with parameters (number progress, string msg, progress_data) (default is undef).
1148 # @param progress_data [optional] (default is undef).
1150 # <a href="http://www.gdal.org/gdal__alg_8h.html">Documentation for GDAL algorithms</a>
1155 #** @method FlushCache()
1157 # Write cached data to disk. There is usually no need to call this
1163 #** @method scalar GetBandNumber()
1165 # @return The index of this band in the parent dataset list of bands.
1170 #** @method GetBlockSize()
1175 #** @method list GetDefaultHistogram($force = 1, coderef progress = undef, $progress_data = undef)
1177 # @param force true to force the computation
1178 # @param progress [optional] a reference to a subroutine, which will
1179 # be called with parameters (number progress, string msg, progress_data)
1180 # @param progress_data [optional]
1181 # @note See Note in Geo::GDAL::Band::GetHistogram.
1182 # @return a list: ($min, $max, arrayref histogram).
1184 sub GetDefaultHistogram {
1187 #** @method list GetHistogram(%parameters)
1189 # Compute histogram from the raster.
1190 # @param parameters Named parameters:
1191 # - \a Min the lower bound, default is -0.5
1192 # - \a Max the upper bound, default is 255.5
1193 # - \a Buckets the number of buckets in the histogram, default is 256
1194 # - \a IncludeOutOfRange whether to use the first and last values in the returned list
1195 # for out of range values, default is false;
1196 # the bucket size is (Max-Min) / Buckets if this is false and
1197 # (Max-Min) / (Buckets-2) if this is true
1198 # - \a ApproxOK if histogram can be computed from overviews, default is false
1199 # - \a Progress an optional progress function, the default is undef
1200 # - \a ProgressData data for the progress function, the default is undef
1201 # @note Histogram counts are treated as strings in the bindings to be
1202 # able to use large integers (if GUIntBig is larger than Perl IV). In
1203 # practice this is only important if you have a 32 bit machine and
1204 # very large bucket counts. In those cases it may also be necessary to
1206 # @return a list which contains the count of values in each bucket
1210 my $p = named_parameters(\@_,
1214 IncludeOutOfRange => 0,
1217 ProgressData => undef);
1218 $p->{progressdata} = 1
if $p->{progress} and not defined $p->{progressdata};
1219 _GetHistogram($self, $p->{min}, $p->{max}, $p->{buckets},
1220 $p->{includeoutofrange}, $p->{approxok},
1221 $p->{progress}, $p->{progressdata});
1224 #** @method Geo::GDAL::Band GetMaskBand()
1226 # @return the mask band associated with this
1231 my $band = _GetMaskBand($self);
1235 #** @method list GetMaskFlags()
1237 # @return the mask flags of the mask band associated with this
1238 # band. The flags are one or more of Geo::GDAL::Band::MaskFlags.
1242 my $f = $self->_GetMaskFlags;
1244 for my $flag (keys %MASK_FLAGS) {
1245 push @f, $flag
if $f & $MASK_FLAGS{$flag};
1247 return wantarray ? @f : $f;
1250 #** @method scalar GetMaximum()
1252 # @note Call Geo::GDAL::Band::ComputeStatistics before calling
1253 # GetMaximum to make sure the value is computed.
1255 # @return statistical minimum of the band or undef if statistics are
1256 # not kept or computed in scalar context. In list context returns the
1257 # maximum value or a (kind of) maximum value supported by the data
1258 # type and a boolean value, which indicates which is the case (true is
1259 # first, false is second).
1264 #** @method scalar GetMinimum()
1266 # @note Call Geo::GDAL::Band::ComputeStatistics before calling
1267 # GetMinimum to make sure the value is computed.
1269 # @return statistical minimum of the band or undef if statistics are
1270 # not kept or computed in scalar context. In list context returns the
1271 # minimum value or a (kind of) minimum value supported by the data
1272 # type and a boolean value, which indicates which is the case (true is
1273 # first, false is second).
1278 #** @method Geo::GDAL::Band GetOverview($index)
1280 # @param index 0..GetOverviewCount-1
1281 # @return a Geo::GDAL::Band object, which represents the internal
1282 # overview band, or undef. if the index is out of bounds.
1285 my ($self, $index) = @_;
1286 my $band = _GetOverview($self, $index);
1290 #** @method scalar GetOverviewCount()
1292 # @return the number of overviews available of the band.
1294 sub GetOverviewCount {
1297 #** @method list GetStatistics($approx_ok, $force)
1299 # @param approx_ok Whether it is allowed to compute the statistics
1300 # based on overviews or similar.
1301 # @param force Whether to force scanning of the whole raster.
1302 # @note Uses Geo::GDAL::Band::ComputeStatistics internally.
1304 # @return a list ($min, $max, $mean, $stddev).
1309 #** @method HasArbitraryOverviews()
1311 # @return true or false.
1313 sub HasArbitraryOverviews {
1316 #** @method list MaskFlags()
1317 # Package subroutine.
1318 # @return the list of mask flags. These are
1319 # - \a AllValid: There are no invalid cell, all mask values will be 255.
1320 # When used this will normally be the only flag set.
1321 # - \a PerDataset: The mask band is shared between all bands on the dataset.
1322 # - \a Alpha: The mask band is actually an alpha band and may have values
1323 # other than 0 and 255.
1324 # - \a NoData: Indicates the mask is actually being generated from NoData values.
1325 # (mutually exclusive of Alpha).
1328 my @f = sort {$MASK_FLAGS{$a} <=> $MASK_FLAGS{$b}} keys %MASK_FLAGS;
1332 #** @method scalar NoDataValue($NoDataValue)
1334 # Get or set the "no data" value.
1335 # @param NoDataValue [optional]
1336 # @note $band->NoDataValue(undef) sets the NoData value to the
1337 # Posix floating point maximum. Use Geo::GDAL::Band::DeleteNoDataValue
1338 # to stop this band using a NoData value.
1339 # @return The NoData value or undef in scalar context. An undef
1340 # value indicates that there is no NoData value associated with this
1346 if (defined $_[0]) {
1347 SetNoDataValue($self, $_[0]);
1349 SetNoDataValue($self, POSIX::FLT_MAX); # hopefully an
"out of range" value
1352 GetNoDataValue($self);
1355 #** @method scalar PackCharacter()
1357 # @return The character to use in Perl pack and unpack for the data of this band.
1364 #** @method Piddle($piddle, $xoff = 0, $yoff = 0, $xsize = <width>, $ysize = <height>, $xdim, $ydim)
1366 # Read or write band data from/into a piddle.
1368 # \note The PDL module must be available for this method to work. Also, you
1369 # should 'use PDL' in the code that you use this method.
1371 # @param piddle [only when writing] The piddle from which to read the data to be written into the band.
1372 # @param xoff, yoff The offset for data in the band, default is top left (0, 0).
1373 # @param xsize, ysize [optional] The size of the window in the band.
1374 # @param xdim, ydim [optional, only when reading from a band] The size of the piddle to create.
1375 # @return A new piddle when reading from a band (no not use when writing into a band).
1378 # TODO: add Piddle sub to dataset too to make Width x Height x Bands piddles
1379 error(
"PDL is not available.") unless $Geo::GDAL::HAVE_PDL;
1381 my $t = $self->{DataType};
1382 unless (defined wantarray) {
1384 error(
"The datatype of the Piddle and the band do not match.")
1385 unless $PDL2DATATYPE{$pdl->get_datatype} == $t;
1386 my ($xoff, $yoff, $xsize, $ysize) = @_;
1389 my $data = $pdl->get_dataref();
1390 my ($xdim, $ydim) = $pdl->dims();
1391 if ($xdim > $self->{XSize} - $xoff) {
1392 warn
"Piddle XSize too large ($xdim) for this raster band (width = $self->{XSize}, offset = $xoff).";
1393 $xdim = $self->{XSize} - $xoff;
1395 if ($ydim > $self->{YSize} - $yoff) {
1396 $ydim = $self->{YSize} - $yoff;
1397 warn
"Piddle YSize too large ($ydim) for this raster band (height = $self->{YSize}, offset = $yoff).";
1401 $self->_WriteRaster($xoff, $yoff, $xsize, $ysize, $data, $xdim, $ydim, $t, 0, 0);
1404 my ($xoff, $yoff, $xsize, $ysize, $xdim, $ydim, $alg) = @_;
1412 $alg = s2i(rio_resampling => $alg);
1413 my $buf = $self->_ReadRaster($xoff, $yoff, $xsize, $ysize, $xdim, $ydim, $t, 0, 0, $alg);
1415 my $datatype = $DATATYPE2PDL{$t};
1416 error(
"The band datatype is not supported by PDL.") if $datatype < 0;
1417 $pdl->set_datatype($datatype);
1418 $pdl->setdims([$xdim, $ydim]);
1419 my $data = $pdl->get_dataref();
1422 # FIXME: we want approximate equality since no data value can be very large floating point value
1423 my $bad = GetNoDataValue($self);
1424 return $pdl->setbadif($pdl == $bad)
if defined $bad;
1428 #** @method Geo::OGR::Layer Polygonize(%params)
1430 # Polygonize this raster band.
1432 # @param params Named parameters:
1433 # - \a Mask A raster band, which is used as a mask to select polygonized areas. Default is undef.
1434 # - \a OutLayer A vector layer into which the polygons are written. If not given, an in-memory layer 'polygonized' is created and returned.
1435 # - \a PixValField The name of the field in the output layer into which the cell value of the polygon area is stored. Default is 'val'.
1436 # - \a Options Hash or list of options. Connectedness can be set to 8
1437 # to use 8-connectedness, otherwise 4-connectedness is
1438 # used. ForceIntPixel can be set to 1 to force using a 32 bit int buffer
1439 # for cell values in the process. If this is not set and the data type
1440 # of this raster does not fit into a 32 bit int buffer, a 32 bit float
1442 # - \a Progress Progress function.
1443 # - \a ProgressData Additional parameter for the progress function.
1445 # @return Output vector layer.
1449 my $p = named_parameters(\@_, Mask => undef, OutLayer => undef, PixValField =>
'val', Options => undef, Progress => undef, ProgressData => undef);
1450 my %known_options = (Connectedness => 1, ForceIntPixel => 1, DATASET_FOR_GEOREF => 1,
'8CONNECTED' => 1);
1451 for my $option (keys %{$p->{options}}) {
1452 error(1, $option, \%known_options) unless exists $known_options{$option};
1454 my $dt = $self->DataType;
1455 my %leInt32 = (Byte => 1, Int16 => 1, Int32 => 1, UInt16 => 1);
1456 my $leInt32 = $leInt32{$dt};
1457 $dt = $dt =~ /Float/ ?
'Real' :
'Integer';
1459 CreateLayer(Name =>
'polygonized',
1460 Fields => [{Name =>
'val', Type => $dt},
1461 {Name =>
'geom', Type =>
'Polygon'}]);
1462 $p->{pixvalfield} = $p->{outlayer}->GetLayerDefn->GetFieldIndex($p->{pixvalfield});
1463 $p->{options}{
'8CONNECTED'} = 1
if $p->{options}{Connectedness} && $p->{options}{Connectedness} == 8;
1464 if ($leInt32 || $p->{options}{ForceIntPixel}) {
1465 Geo::GDAL::_Polygonize($self, $p->{mask}, $p->{outlayer}, $p->{pixvalfield}, $p->{options}, $p->{progress}, $p->{progressdata});
1467 Geo::GDAL::FPolygonize($self, $p->{mask}, $p->{outlayer}, $p->{pixvalfield}, $p->{options}, $p->{progress}, $p->{progressdata});
1469 set the srs of the outlayer
if it was created here
1470 return $p->{outlayer};
1473 #** @method RasterAttributeTable()
1475 sub RasterAttributeTable {
1478 #** @method scalar ReadRaster(%params)
1480 # Read data from the band.
1482 # @param params Named parameters:
1483 # - \a XOff x offset (cell coordinates) (default is 0)
1484 # - \a YOff y offset (cell coordinates) (default is 0)
1485 # - \a XSize width of the area to read (default is the width of the band)
1486 # - \a YSize height of the area to read (default is the height of the band)
1487 # - \a BufXSize (default is undef, i.e., the same as XSize)
1488 # - \a BufYSize (default is undef, i.e., the same as YSize)
1489 # - \a BufType data type of the buffer (default is the data type of the band)
1490 # - \a BufPixelSpace (default is 0)
1491 # - \a BufLineSpace (default is 0)
1492 # - \a ResampleAlg one of Geo::GDAL::RIOResamplingTypes (default is 'NearestNeighbour'),
1493 # - \a Progress reference to a progress function (default is undef)
1494 # - \a ProgressData (default is undef)
1496 # <a href="http://www.gdal.org/classGDALDataset.html">Entry in GDAL docs (method RasterIO)</a>
1497 # @return a buffer, open the buffer with \a unpack function of Perl. See Geo::GDAL::Band::PackCharacter.
1501 my ($width, $height) = $self->Size;
1502 my ($type) = $self->DataType;
1503 my $p = named_parameters(\@_,
1513 ResampleAlg =>
'NearestNeighbour',
1515 ProgressData => undef
1517 $p->{resamplealg} = s2i(rio_resampling => $p->{resamplealg});
1518 $p->{buftype} = s2i(data_type => $p->{buftype}, 1);
1519 $self->_ReadRaster($p->{xoff},$p->{yoff},$p->{xsize},$p->{ysize},$p->{bufxsize},$p->{bufysize},$p->{buftype},$p->{bufpixelspace},$p->{buflinespace},$p->{resamplealg},$p->{progress},$p->{progressdata});
1522 #** @method array reference ReadTile($xoff = 0, $yoff = 0, $xsize = <width>, $ysize = <height>)
1524 # Read band data into a Perl array.
1526 # \note Accessing band data in this way is slow. Consider using PDL and Geo::GDAL::Band::Piddle.
1528 # Usage example (print the data from a band):
1530 # print "@$_\n" for ( @{ $band->ReadTile() } );
1532 # Another usage example (process the data of a large dataset that has one band):
1534 # my($W,$H) = $dataset->Band()->Size();
1535 # my($xoff,$yoff,$w,$h) = (0,0,200,200);
1537 # if ($xoff >= $W) {
1540 # last if $yoff >= $H;
1542 # my $data = $dataset->Band(1)->ReadTile($xoff,$yoff,min($W-$xoff,$w),min($H-$yoff,$h));
1543 # # add your data processing code here
1544 # $dataset->Band(1)->WriteTile($data,$xoff,$yoff);
1549 # return $_[0] < $_[1] ? $_[0] : $_[1];
1552 # @param xoff Number of cell to skip before starting to read from a row. Pixels are read from left to right.
1553 # @param yoff Number of cells to skip before starting to read from a column. Pixels are read from top to bottom.
1554 # @param xsize Number of cells to read from each row.
1555 # @param ysize Number of cells to read from each column.
1556 # @return a two-dimensional Perl array, organizes as data->[y][x], y =
1557 # 0..height-1, x = 0..width-1. I.e., y is row and x is column.
1560 my($self, $xoff, $yoff, $xsize, $ysize, $w_tile, $h_tile, $alg) = @_;
1568 $alg = s2i(rio_resampling => $alg);
1569 my $t = $self->{DataType};
1570 my $buf = $self->_ReadRaster($xoff, $yoff, $xsize, $ysize, $w_tile, $h_tile, $t, 0, 0, $alg);
1575 for my $y (0..$h_tile-1) {
1576 my @d = unpack($pc.
"[$w_tile]", substr($buf, $offset, $w));
1583 #** @method Reclassify($classifier, $progress = undef, $progress_data = undef)
1585 # Reclassify the cells in the band.
1586 # @note NoData values in integer rasters are reclassified if
1587 # explicitly specified in the hash classifier. However, they are not
1588 # reclassified to the default value, if one is specified. In real
1589 # valued rasters nodata cells are not reclassified.
1590 # @note If the subroutine is user terminated or the classifier is
1591 # incorrect, already reclassified cells will stay reclassified but an
1593 # @param classifier For integer rasters an anonymous hash, which
1594 # contains old class values as keys and new class values as values, or
1595 # an array classifier as in Geo::GDAL::Band::ClassCounts. In a hash
1596 # classifier a special key '*' (star) can be used as default, to act
1597 # as a fallback new class value. For real valued rasters the
1598 # classifier is as in Geo::GDAL::Band::ClassCounts.
1603 #** @method RegenerateOverview(Geo::GDAL::Band overview, $resampling, coderef progress, $progress_data)
1605 # @param overview a Geo::GDAL::Band object for the overview.
1606 # @param resampling [optional] the resampling method (one of Geo::GDAL::RIOResamplingTypes) (default is Average).
1607 # @param progress [optional] a reference to a subroutine, which will
1608 # be called with parameters (number progress, string msg, progress_data)
1609 # @param progress_data [optional]
1611 sub RegenerateOverview {
1613 #Geo::GDAL::Band overview, scalar resampling, subref callback, scalar callback_data
1615 Geo::GDAL::RegenerateOverview($self, @p);
1618 #** @method RegenerateOverviews(arrayref overviews, $resampling, coderef progress, $progress_data)
1620 # @todo This is not yet available
1622 # @param overviews a list of Geo::GDAL::Band objects for the overviews.
1623 # @param resampling [optional] the resampling method (one of Geo::GDAL::RIOResamplingTypes) (default is Average).
1624 # @param progress [optional] a reference to a subroutine, which will
1625 # be called with parameters (number progress, string msg, progress_data)
1626 # @param progress_data [optional]
1628 sub RegenerateOverviews {
1630 #arrayref overviews, scalar resampling, subref callback, scalar callback_data
1632 Geo::GDAL::RegenerateOverviews($self, @p);
1635 #** @method ScaleAndOffset($scale, $offset)
1637 # Scale and offset are used to transform raw cell values into the
1638 # units returned by GetUnits(). The conversion function is:
1640 # Units value = (raw value * scale) + offset
1642 # @return a list ($scale, $offset), the values are undefined if they
1644 # @since version 1.9 of the bindings.
1646 sub ScaleAndOffset {
1648 SetScale($self, $_[0])
if @_ > 0 and defined $_[0];
1649 SetOffset($self, $_[1])
if @_ > 1 and defined $_[1];
1650 return unless defined wantarray;
1651 my $scale = GetScale($self);
1652 my $offset = GetOffset($self);
1653 return ($scale, $offset);
1656 #** @method list SetDefaultHistogram($min, $max, $histogram)
1660 # @note See Note in Geo::GDAL::Band::GetHistogram.
1661 # @param histogram reference to an array containing the histogram
1663 sub SetDefaultHistogram {
1666 #** @method SetStatistics($min, $max, $mean, $stddev)
1668 # Save the statistics of the band if possible (the format can save
1669 # arbitrary metadata).
1678 #** @method Geo::GDAL::Band Sieve(%params)
1680 # Remove small areas by merging them into the largest neighbour area.
1681 # @param params Named parameters:
1682 # - \a Mask A raster band, which is used as a mask to select sieved areas. Default is undef.
1683 # - \a Dest A raster band into which the result is written. If not given, an new in-memory raster band is created and returned.
1684 # - \a Threshold The smallest area size (in number of cells) which are not sieved away.
1685 # - \a Options Hash or list of options. {Connectedness => 4} can be specified to use 4-connectedness, otherwise 8-connectedness is used.
1686 # - \a Progress Progress function.
1687 # - \a ProgressData Additional parameter for the progress function.
1689 # @return The filtered raster band.
1693 my $p = named_parameters(\@_, Mask => undef, Dest => undef, Threshold => 10, Options => undef, Progress => undef, ProgressData => undef);
1694 unless ($p->{dest}) {
1695 my ($w, $h) = $self->Size;
1699 if ($p->{options}{Connectedness}) {
1700 $c = $p->{options}{Connectedness};
1701 delete $p->{options}{Connectedness};
1703 Geo::GDAL::SieveFilter($self, $p->{mask}, $p->{dest}, $p->{threshold}, $c, $p->{options}, $p->{progress}, $p->{progressdata});
1707 #** @method list Size()
1709 # @return The size of the band as a list (width, height).
1713 return ($self->{XSize}, $self->{YSize});
1716 #** @method Unit($type)
1718 # @param type [optional] the unit (a string).
1719 # @note $band->Unit(undef) sets the unit value to an empty string.
1720 # @return the unit (a string).
1721 # @since version 1.9 of the bindings.
1728 SetUnitType($self, $unit);
1730 return unless defined wantarray;
1734 #** @method WriteRaster(%params)
1736 # Write data into the band.
1738 # @param params Named parameters:
1739 # - \a XOff x offset (cell coordinates) (default is 0)
1740 # - \a YOff y offset (cell coordinates) (default is 0)
1741 # - \a XSize width of the area to write (default is the width of the band)
1742 # - \a YSize height of the area to write (default is the height of the band)
1743 # - \a Buf a buffer (or a reference to a buffer) containing the data. Create the buffer with \a pack function of Perl. See Geo::GDAL::Band::PackCharacter.
1744 # - \a BufXSize (default is undef, i.e., the same as XSize)
1745 # - \a BufYSize (default is undef, i.e., the same as YSize)
1746 # - \a BufType data type of the buffer (default is the data type of the band)
1747 # - \a BufPixelSpace (default is 0)
1748 # - \a BufLineSpace (default is 0)
1750 # <a href="http://www.gdal.org/classGDALDataset.html">Entry in GDAL docs (method RasterIO)</a>
1754 my ($width, $height) = $self->Size;
1755 my ($type) = $self->DataType;
1756 my $p = named_parameters(\@_,
1768 confess
"Usage: \$band->WriteRaster( Buf => \$data, ... )" unless defined $p->{buf};
1769 $p->{buftype} = s2i(data_type => $p->{buftype}, 1);
1770 $self->_WriteRaster($p->{xoff},$p->{yoff},$p->{xsize},$p->{ysize},$p->{buf},$p->{bufxsize},$p->{bufysize},$p->{buftype},$p->{bufpixelspace},$p->{buflinespace});
1773 #** @method WriteTile($data, $xoff = 0, $yoff = 0)
1775 # Write band data from a Perl array.
1777 # \note Accessing band data in this way is slow. Consider using PDL and Geo::GDAL::Band::Piddle.
1779 # @param data A two-dimensional Perl array, organizes as data->[y][x], y =
1780 # 0..height-1, x = 0..width-1.
1786 my($self, $data, $xoff, $yoff) = @_;
1789 error(
'The data must be in a two-dimensional array') unless ref $data eq
'ARRAY' && ref $data->[0] eq
'ARRAY';
1790 my $xsize = @{$data->[0]};
1791 if ($xsize > $self->{XSize} - $xoff) {
1792 warn
"Buffer XSize too large ($xsize) for this raster band (width = $self->{XSize}, offset = $xoff).";
1793 $xsize = $self->{XSize} - $xoff;
1795 my $ysize = @{$data};
1796 if ($ysize > $self->{YSize} - $yoff) {
1797 $ysize = $self->{YSize} - $yoff;
1798 warn
"Buffer YSize too large ($ysize) for this raster band (height = $self->{YSize}, offset = $yoff).";
1801 for my $i (0..$ysize-1) {
1802 my $scanline = pack($pc.
"[$xsize]", @{$data->[$i]});
1803 $self->WriteRaster( $xoff, $yoff+$i, $xsize, 1, $scanline );
1807 #** @class Geo::GDAL::ColorTable
1808 # @brief A color table from a raster band or a color table, which can be used for a band.
1811 package Geo::GDAL::ColorTable;
1815 #** @method Geo::GDAL::ColorTable Clone()
1817 # Clone an existing color table.
1818 # @return a new Geo::GDAL::ColorTable object
1823 #** @method list Color($index, @color)
1825 # Get or set a color in this color table.
1826 # @param index The index of the color in the table. Note that the
1827 # color table may expand if the index is larger than the current max
1828 # index of this table and a color is given. An attempt to retrieve a
1829 # color out of the current size of the table causes an error.
1830 # @param color [optional] The color, either a list or a reference to a
1831 # list. If the list is too short or has undef values, the undef values
1832 # are taken as 0 except for alpha, which is taken as 255.
1833 # @note A color is an array of four integers having a value between 0
1834 # and 255: (gray, red, cyan or hue; green, magenta, or lightness;
1835 # blue, yellow, or saturation; alpha or blackband)
1836 # @return A color, in list context a list and in scalar context a reference to an anonymous array.
1841 #** @method list Colors(@colors)
1843 # Get or set the colors in this color table.
1844 # @note The color table will expand to the size of the input list but
1845 # it will not shrink.
1846 # @param colors [optional] A list of all colors (a list of lists) for this color table.
1847 # @return A list of colors (a list of lists).
1852 #** @method CreateColorRamp($start_index, arrayref start_color, $end_index, arrayref end_color)
1854 # @param start_index
1855 # @param start_color
1859 sub CreateColorRamp {
1862 #** @method scalar GetCount()
1864 # @return The number of colors in this color table.
1869 #** @method scalar GetPaletteInterpretation()
1871 # @return palette interpretation (string)
1873 sub GetPaletteInterpretation {
1875 return i2s(palette_interpretation => GetPaletteInterpretation($self));
1878 #** @method Geo::GDAL::ColorTable new($GDALPaletteInterp = 'RGB')
1880 # Create a new empty color table.
1881 # @return a new Geo::GDAL::ColorTable object
1886 $pi = s2i(palette_interpretation => $pi);
1887 my $self = Geo::GDALc::new_ColorTable($pi);
1888 bless $self, $pkg
if defined($self);
1891 #** @class Geo::GDAL::Dataset
1892 # @brief A set of associated raster bands or vector layer source.
1895 package Geo::GDAL::Dataset;
1899 #** @attr $RasterCount
1900 # scalar (access as $dataset->{RasterCount})
1903 #** @attr $RasterXSize
1904 # scalar (access as $dataset->{RasterXSize})
1907 #** @attr $RasterYSize
1908 # scalar (access as $dataset->{RasterYSize})
1911 #** @method AbortSQL()
1916 #** @method AddBand($datatype = 'Byte', hashref options = {})
1918 # Add a new band to the dataset. The driver must support the action.
1919 # @param datatype GDAL raster cell data type (one of those listed by Geo::GDAL::DataTypes).
1920 # @param options reference to a hash of format specific options.
1921 # @return The added band.
1924 my ($self, $type, $options) = @_;
1926 $type = s2i(data_type => $type);
1927 $self->_AddBand($type, $options);
1928 return unless defined wantarray;
1929 return $self->GetRasterBand($self->{RasterCount});
1932 #** @method AddFieldDomain()
1934 sub AddFieldDomain {
1937 #** @method AdviseRead()
1942 #** @method Geo::GDAL::Band Band($index)
1944 # Create a band object for the band within the dataset.
1945 # @note a.k.a. GetRasterBand
1946 # @param index 1...RasterCount, default is 1.
1947 # @return a new Geo::GDAL::Band object
1952 #** @method list Bands()
1954 # @return a list of new Geo::GDAL::Band objects
1959 for my $i (1..$self->{RasterCount}) {
1960 push @bands, GetRasterBand($self, $i);
1965 #** @method BuildOverviews($resampling, arrayref overviews, coderef progress, $progress_data)
1967 # @param resampling the resampling method, one of Geo::GDAL::RIOResamplingTypes.
1968 # @param overviews The list of overview decimation factors to
1969 # build. For example [2,4,8].
1970 # @param progress [optional] a reference to a subroutine, which will
1971 # be called with parameters (number progress, string msg, progress_data)
1972 # @param progress_data [optional]
1974 sub BuildOverviews {
1977 $p[0] = uc($p[0])
if $p[0];
1979 $self->_BuildOverviews(@p);
1981 confess(last_error()) if $@;
1984 #** @method Geo::GDAL::Dataset BuildVRT($Dest, arrayref Sources, hashref Options, coderef progress, $progress_data)
1986 # Build a virtual dataset from a set of datasets.
1987 # @param Dest Destination raster dataset definition string (typically
1988 # filename), or an object, which implements write and close.
1989 # @param Sources A list of filenames of input datasets or a list of
1991 # @param Options See section \ref index_processing_options.
1992 # @return Dataset object
1994 # @note This subroutine is imported into the main namespace if Geo::GDAL
1995 # is use'd with qw/:all/.
1998 my ($dest, $sources, $options, $progress, $progress_data) = @_;
1999 $options = Geo::GDAL::GDALBuildVRTOptions->new(make_processing_options($options));
2000 error(
"Usage: Geo::GDAL::DataSet::BuildVRT(\$vrt_file_name, \\\@sources)")
2001 unless ref $sources eq
'ARRAY' && defined $sources->[0];
2002 unless (blessed($dest)) {
2003 if (blessed($sources->[0])) {
2004 return Geo::GDAL::wrapper_GDALBuildVRT_objects($dest, $sources, $options, $progress, $progress_data);
2006 return Geo::GDAL::wrapper_GDALBuildVRT_names($dest, $sources, $options, $progress, $progress_data);
2009 if (blessed($sources->[0])) {
2010 return stdout_redirection_wrapper(
2012 \&Geo::GDAL::wrapper_GDALBuildVRT_objects,
2013 $options, $progress, $progress_data);
2015 return stdout_redirection_wrapper(
2017 \&Geo::GDAL::wrapper_GDALBuildVRT_names,
2018 $options, $progress, $progress_data);
2023 #** @method ClearStatistics()
2025 sub ClearStatistics {
2028 #** @method CommitTransaction()
2030 sub CommitTransaction {
2033 #** @method Geo::GDAL::ColorTable ComputeColorTable(%params)
2035 # Compute a color table from an RGB image
2036 # @param params Named parameters:
2037 # - \a Red The red band, the default is to use the red band of this dataset.
2038 # - \a Green The green band, the default is to use the green band of this dataset.
2039 # - \a Blue The blue band, the default is to use the blue band of this dataset.
2040 # - \a NumColors The number of colors in the computed color table. Default is 256.
2041 # - \a Progress reference to a progress function (default is undef)
2042 # - \a ProgressData (default is undef)
2043 # - \a Method The computation method. The default and currently only option is the median cut algorithm.
2045 # @return a new color table object.
2047 sub ComputeColorTable {
2049 my $p = named_parameters(\@_,
2055 ProgressData => undef,
2056 Method =>
'MedianCut');
2057 for my $b ($self->Bands) {
2058 for my $cion ($b->ColorInterpretation) {
2059 if ($cion eq
'RedBand') { $p->{red}
2060 if ($cion eq
'GreenBand') { $p->{green}
2061 if ($cion eq
'BlueBand') { $p->{blue}
2065 Geo::GDAL::ComputeMedianCutPCT($p->{red},
2069 $ct, $p->{progress},
2070 $p->{progressdata});
2074 #** @method Geo::OGR::Layer CopyLayer($layer, $name, hashref options = undef)
2076 # @param layer A Geo::OGR::Layer object to be copied.
2077 # @param name A name for the new layer.
2078 # @param options A ref to a hash of format specific options.
2079 # @return a new Geo::OGR::Layer object.
2084 #** @method Geo::OGR::Layer CreateLayer(%params)
2086 # @brief Create a new vector layer into this dataset.
2088 # @param %params Named parameters:
2089 # - \a Name (scalar) name for the new layer.
2090 # - \a Fields (array reference) a list of (scalar and geometry) field definitions as in
2091 # Geo::OGR::Layer::CreateField.
2092 # - \a ApproxOK (boolean value, default is true) a flag, which is forwarded to Geo::OGR::Layer::CreateField.
2093 # - \a Options (hash reference) driver specific hash of layer creation options.
2094 # - \a Schema (hash reference, deprecated, use \a Fields and \a Name) may contain keys Name, Fields, GeomFields, GeometryType.
2095 # - \a SRS (scalar) the spatial reference for the default geometry field.
2096 # - \a GeometryType (scalar) the type of the default geometry field
2097 # (if only one geometry field). Default is 'Unknown'.
2099 # @note If Fields or Schema|Fields is not given, a default geometry
2100 # field (Name => '', GeometryType => 'Unknown') is created. If it is
2101 # given and it contains spatial fields, both GeometryType and SRS are
2102 # ignored. The type can be also set with the named parameter.
2106 # my $roads = Geo::OGR::Driver('Memory')->Create('road')->
2108 # Fields => [ { Name => 'class',
2109 # Type => 'Integer' },
2111 # Type => 'LineString25D' } ] );
2114 # @note Many formats allow only one spatial field, which currently
2115 # requires the use of GeometryType.
2117 # @return a new Geo::OGR::Layer object.
2121 my $p = named_parameters(\@_,
2124 GeometryType =>
'Unknown',
2129 error(
"The 'Fields' argument must be an array reference.") if $p->{fields} && ref($p->{fields}) ne
'ARRAY';
2130 if (defined $p->{schema}) {
2131 my $s = $p->{schema};
2132 $p->{geometrytype} = $s->{GeometryType}
if exists $s->{GeometryType};
2133 $p->{fields} = $s->{Fields}
if exists $s->{Fields};
2134 $p->{name} = $s->{Name}
if exists $s->{Name};
2136 $p->{fields} = [] unless ref($p->{fields}) eq
'ARRAY';
2137 # if fields contains spatial fields, then do not create default one
2138 for my $f (@{$p->{fields}}) {
2139 error(
"Field definitions must be hash references.") unless ref $f eq 'HASH';
2140 if ($f->{GeometryType} || ($f->{Type} && s_exists(geometry_type => $f->{Type}))) {
2141 $p->{geometrytype} =
'None';
2145 my $gt = s2i(geometry_type => $p->{geometrytype});
2146 my $layer = _CreateLayer($self, $p->{name}, $p->{srs}, $gt, $p->{options});
2147 for my $f (@{$p->{fields}}) {
2148 $layer->CreateField($f);
2150 keep($layer, $self);
2153 #** @method CreateMaskBand()
2155 # Add a mask band to the dataset.
2157 sub CreateMaskBand {
2158 return _CreateMaskBand(@_);
2161 #** @method Geo::GDAL::Dataset DEMProcessing($Dest, $Processing, $ColorFilename, hashref Options, coderef progress, $progress_data)
2163 # Apply a DEM processing to this dataset.
2164 # @param Dest Destination raster dataset definition string (typically filename) or an object, which implements write and close.
2165 # @param Processing Processing to apply, one of "hillshade", "slope", "aspect", "color-relief", "TRI", "TPI", or "Roughness".
2166 # @param ColorFilename The color palette for color-relief.
2167 # @param Options See section \ref index_processing_options.
2168 # @param progress [optional] A reference to a subroutine, which will
2169 # be called with parameters (number progress, string msg, progress_data).
2170 # @param progress_data [optional]
2174 my ($self, $dest, $Processing, $ColorFilename, $options, $progress, $progress_data) = @_;
2175 $options = Geo::GDAL::GDALDEMProcessingOptions->new(make_processing_options($options));
2176 return $self->stdout_redirection_wrapper(
2178 \&Geo::GDAL::wrapper_GDALDEMProcessing,
2179 $Processing, $ColorFilename, $options, $progress, $progress_data
2183 #** @method Dataset()
2190 #** @method DeleteLayer($name)
2192 # Deletes a layer from the data source. Note that if there is a layer
2193 # object for the deleted layer, it becomes unusable.
2194 # @param name name of the layer to delete.
2197 my ($self, $name) = @_;
2199 for my $i (0..$self->GetLayerCount-1) {
2200 my $layer = GetLayerByIndex($self, $i);
2201 $index = $i, last
if $layer->GetName eq $name;
2203 error(2, $name,
'Layer') unless defined $index;
2204 _DeleteLayer($self, $index);
2207 #** @method Geo::GDAL::Band Dither(%params)
2209 # Compute one band with color table image from an RGB image
2210 # @params params Named parameters:
2211 # - \a Red The red band, the default is to use the red band of this dataset.
2212 # - \a Green The green band, the default is to use the green band of this dataset.
2213 # - \a Blue The blue band, the default is to use the blue band of this dataset.
2214 # - \a Dest The destination band. If this is not defined, a new in-memory band (and a dataset) will be created.
2215 # - \a ColorTable The color table for the result. If this is not defined, and the destination band does not contain one, it will be computed with the ComputeColorTable method.
2216 # - \a Progress Reference to a progress function (default is undef). Note that if ColorTable is computed using ComputeColorTable method, the progress will run twice from 0 to 1.
2217 # - \a ProgressData (default is undef)
2219 # @return the destination band.
2221 # Usage example. This code converts an RGB JPEG image into a one band PNG image with a color table.
2223 # my $d = Geo::GDAL::Open('pic.jpg');
2224 # Geo::GDAL::Driver('PNG')->Copy(Name => 'test.png', Src => $d->Dither->Dataset);
2229 my $p = named_parameters(\@_,
2236 ProgressData => undef);
2237 for my $b ($self->Bands) {
2238 for my $cion ($b->ColorInterpretation) {
2239 if ($cion eq
'RedBand') { $p->{red}
2240 if ($cion eq
'GreenBand') { $p->{green}
2241 if ($cion eq
'BlueBand') { $p->{blue}
2244 my ($w, $h) = $self->Size;
2248 Type =>
'Byte')->
Band;
2252 Green => $p->{green},
2254 Progress => $p->{progress},
2255 ProgressData => $p->{progressdata});
2256 Geo::GDAL::DitherRGB2PCT($p->{red},
2262 $p->{progressdata});
2267 #** @method Domains()
2273 #** @method Geo::GDAL::Driver Driver()
2275 # @note a.k.a. GetDriver
2276 # @return a Geo::GDAL::Driver object that was used to open or create this dataset.
2281 #** @method Geo::OGR::Layer ExecuteSQL($statement, $geom = undef, $dialect = "")
2283 # @param statement A SQL statement.
2284 # @param geom A Geo::OGR::Geometry object.
2286 # @return a new Geo::OGR::Layer object. The data source object will
2287 # exist as long as the layer object exists.
2291 my $layer = $self->_ExecuteSQL(@_);
2292 note($layer,
"is result set");
2293 keep($layer, $self);
2296 #** @method Geo::GDAL::Extent Extent(@params)
2298 # @param params nothing, or a list ($xoff, $yoff, $w, $h)
2299 # @return A new Geo::GDAL::Extent object that represents the area that
2300 # this raster or the specified tile covers.
2304 my $t = $self->GeoTransform;
2305 my $extent = $t->Extent($self->Size);
2307 my ($xoff, $yoff, $w, $h) = @_;
2308 my ($x, $y) = $t->Apply([$xoff, $xoff+$w, $xoff+$w, $xoff], [$yoff, $yoff, $yoff+$h, $yoff+$h]);
2309 my $xmin = shift @$x;
2312 $xmin = $x
if $x < $xmin;
2313 $xmax = $x
if $x > $xmax;
2315 my $ymin = shift @$y;
2318 $ymin = $y
if $y < $ymin;
2319 $ymax = $y
if $y > $ymax;
2326 #** @method list GCPs(@GCPs, Geo::OSR::SpatialReference sr)
2328 # Get or set the GCPs and their projection.
2329 # @param GCPs [optional] a list of Geo::GDAL::GCP objects
2330 # @param sr [optional] the projection of the GCPs.
2331 # @return a list of Geo::GDAL::GCP objects followed by a Geo::OSR::SpatialReference object.
2337 $proj = $proj->Export(
'WKT')
if $proj and ref($proj);
2338 SetGCPs($self, \@_, $proj);
2340 return unless defined wantarray;
2342 my $GCPs = GetGCPs($self);
2343 return (@$GCPs, $proj);
2346 #** @method Geo::GDAL::GeoTransform GeoTransform(Geo::GDAL::GeoTransform $geo_transform)
2348 # Transformation from cell coordinates (column,row) to projection
2351 # x = geo_transform[0] + column*geo_transform[1] + row*geo_transform[2]
2352 # y = geo_transform[3] + column*geo_transform[4] + row*geo_transform[5]
2354 # @param geo_transform [optional]
2355 # @return the geo transform in a non-void context.
2361 SetGeoTransform($self, $_[0]);
2363 SetGeoTransform($self, \@_);
2366 confess(last_error()) if $@;
2367 return unless defined wantarray;
2368 my $t = GetGeoTransform($self);
2376 #** @method GetDriver()
2381 #** @method GetFieldDomain()
2383 sub GetFieldDomain {
2386 #** @method list GetFileList()
2388 # @return list of files GDAL believes to be part of this dataset.
2393 #** @method scalar GetGCPProjection()
2395 # @return projection string.
2397 sub GetGCPProjection {
2400 #** @method GetGCPSpatialRef()
2402 sub GetGCPSpatialRef {
2405 #** @method Geo::OGR::Layer GetLayer($name)
2407 # @param name the name of the requested layer. If not given, then
2408 # returns the first layer in the data source.
2409 # @return a new Geo::OGR::Layer object that represents the layer
2410 # in the data source.
2413 my($self, $name) = @_;
2414 my $layer = defined $name ? GetLayerByName($self,
"$name") : GetLayerByIndex($self, 0);
2416 error(2, $name,
'Layer') unless $layer;
2417 keep($layer, $self);
2420 #** @method list GetLayerNames()
2422 # @note Delivers the functionality of undocumented method GetLayerCount.
2423 # @return a list of the names of the layers this data source provides.
2428 for my $i (0..$self->GetLayerCount-1) {
2429 my $layer = GetLayerByIndex($self, $i);
2430 push @names, $layer->GetName;
2435 #** @method GetNextFeature()
2437 sub GetNextFeature {
2440 #** @method GetRootGroup()
2445 #** @method GetSpatialRef()
2450 #** @method GetStyleTable()
2455 #** @method Geo::GDAL::Dataset Grid($Dest, hashref Options)
2457 # Creates a regular raster grid from this data source.
2458 # This is equivalent to the gdal_grid utility.
2459 # @param Dest Destination raster dataset definition string (typically
2460 # filename) or an object, which implements write and close.
2461 # @param Options See section \ref index_processing_options.
2464 my ($self, $dest, $options, $progress, $progress_data) = @_;
2465 $options = Geo::GDAL::GDALGridOptions->new(make_processing_options($options));
2466 return $self->stdout_redirection_wrapper(
2468 \&Geo::GDAL::wrapper_GDALGrid,
2469 $options, $progress, $progress_data
2473 #** @method scalar Info(hashref Options)
2475 # Information about this dataset.
2476 # @param Options See section \ref index_processing_options.
2479 my ($self, $o) = @_;
2480 $o = Geo::GDAL::GDALInfoOptions->new(make_processing_options($o));
2481 return GDALInfo($self, $o);
2484 #** @method IsLayerPrivate()
2486 sub IsLayerPrivate {
2489 #** @method Geo::GDAL::Dataset Nearblack($Dest, hashref Options, coderef progress, $progress_data)
2491 # Convert nearly black/white pixels to black/white.
2492 # @param Dest Destination raster dataset definition string (typically
2493 # filename), destination dataset to which to add an alpha or mask
2494 # band, or an object, which implements write and close.
2495 # @param Options See section \ref index_processing_options.
2496 # @return Dataset if destination dataset definition string was given,
2497 # otherwise a boolean for success/fail but the method croaks if there
2501 my ($self, $dest, $options, $progress, $progress_data) = @_;
2502 $options = Geo::GDAL::GDALNearblackOptions->new(make_processing_options($options));
2503 my $b = blessed($dest);
2504 if ($b && $b eq
'Geo::GDAL::Dataset') {
2505 Geo::GDAL::wrapper_GDALNearblackDestDS($dest, $self, $options, $progress, $progress_data);
2507 return $self->stdout_redirection_wrapper(
2509 \&Geo::GDAL::wrapper_GDALNearblackDestName,
2510 $options, $progress, $progress_data
2515 #** @method Geo::GDAL::Dataset Open()
2516 # Package subroutine.
2517 # The same as Geo::GDAL::Open
2522 #** @method Geo::GDAL::Dataset OpenShared()
2523 # Package subroutine.
2524 # The same as Geo::GDAL::OpenShared
2529 #** @method Geo::GDAL::Dataset Rasterize($Dest, hashref Options, coderef progress, $progress_data)
2531 # Render data from this data source into a raster.
2532 # @param Dest Destination raster dataset definition string (typically
2533 # filename), destination dataset, or an object, which implements write and close.
2534 # @param Options See section \ref index_processing_options.
2535 # @return Dataset if destination dataset definition string was given,
2536 # otherwise a boolean for success/fail but the method croaks if there
2541 my ($self, $dest, $options, $progress, $progress_data) = @_;
2542 $options = Geo::GDAL::GDALRasterizeOptions->new(make_processing_options($options));
2543 my $b = blessed($dest);
2544 if ($b && $b eq
'Geo::GDAL::Dataset') {
2545 Geo::GDAL::wrapper_GDALRasterizeDestDS($dest, $self, $options, $progress, $progress_data);
2547 # TODO: options need to force a new raster be made, otherwise segfault
2548 return $self->stdout_redirection_wrapper(
2550 \&Geo::GDAL::wrapper_GDALRasterizeDestName,
2551 $options, $progress, $progress_data
2556 #** @method scalar ReadRaster(%params)
2558 # Read data from the dataset.
2560 # @param params Named parameters:
2561 # - \a XOff x offset (cell coordinates) (default is 0)
2562 # - \a YOff y offset (cell coordinates) (default is 0)
2563 # - \a XSize width of the area to read (default is the width of the dataset)
2564 # - \a YSize height of the area to read (default is the height of the dataset)
2565 # - \a BufXSize (default is undef, i.e., the same as XSize)
2566 # - \a BufYSize (default is undef, i.e., the same as YSize)
2567 # - \a BufType data type of the buffer (default is the data type of the first band)
2568 # - \a BandList a reference to an array of band indices (default is [1])
2569 # - \a BufPixelSpace (default is 0)
2570 # - \a BufLineSpace (default is 0)
2571 # - \a BufBandSpace (default is 0)
2572 # - \a ResampleAlg one of Geo::GDAL::RIOResamplingTypes (default is 'NearestNeighbour'),
2573 # - \a Progress reference to a progress function (default is undef)
2574 # - \a ProgressData (default is undef)
2576 # <a href="http://www.gdal.org/classGDALDataset.html">Entry in GDAL docs (method RasterIO)</a>
2577 # @return a buffer, open the buffer with \a unpack function of Perl. See Geo::GDAL::Band::PackCharacter.
2581 my ($width, $height) = $self->Size;
2582 my ($type) = $self->Band->DataType;
2583 my $p = named_parameters(\@_,
2595 ResampleAlg =>
'NearestNeighbour',
2597 ProgressData => undef
2599 $p->{resamplealg} = s2i(rio_resampling => $p->{resamplealg});
2600 $p->{buftype} = s2i(data_type => $p->{buftype}, 1);
2601 $self->_ReadRaster($p->{xoff},$p->{yoff},$p->{xsize},$p->{ysize},$p->{bufxsize},$p->{bufysize},$p->{buftype},$p->{bandlist},$p->{bufpixelspace},$p->{buflinespace},$p->{bufbandspace},$p->{resamplealg},$p->{progress},$p->{progressdata});
2604 #** @method ReadTile()
2607 my ($self, $xoff, $yoff, $xsize, $ysize, $w_tile, $h_tile, $alg) = @_;
2609 for my $i (0..$self->Bands-1) {
2610 $data[$i] = $self->Band($i+1)->ReadTile($xoff, $yoff, $xsize, $ysize, $w_tile, $h_tile, $alg);
2615 #** @method ReleaseResultSet($layer)
2617 # @param layer A layer the has been created with ExecuteSQL.
2618 # @note There is no need to call this method. The result set layer is
2619 # released in the destructor of the layer that was created with SQL.
2621 sub ReleaseResultSet {
2622 # a no-op, _ReleaseResultSet is called from Layer::DESTROY
2625 #** @method ResetReading()
2630 #** @method RollbackTransaction()
2632 sub RollbackTransaction {
2635 #** @method SetGCPs2()
2640 #** @method SetSpatialRef()
2645 #** @method SetStyleTable()
2650 #** @method list Size()
2652 # @return (width, height)
2656 return ($self->{RasterXSize}, $self->{RasterYSize});
2659 #** @method Geo::OSR::SpatialReference SpatialReference(Geo::OSR::SpatialReference sr)
2661 # Get or set the projection of this dataset.
2662 # @param sr [optional] a Geo::OSR::SpatialReference object,
2663 # which replaces the existing projection definition of this dataset.
2664 # @return a Geo::OSR::SpatialReference object, which represents the
2665 # projection of this dataset.
2666 # @note Methods GetProjection, SetProjection, and Projection return WKT strings.
2668 sub SpatialReference {
2669 my($self, $sr) = @_;
2670 SetProjection($self, $sr->As(
'WKT'))
if defined $sr;
2671 if (defined wantarray) {
2672 my $p = GetProjection($self);
2678 #** @method StartTransaction()
2680 sub StartTransaction {
2683 #** @method TestCapability()
2685 sub TestCapability {
2686 return _TestCapability(@_);
2689 #** @method Tile(Geo::GDAL::Extent e)
2691 # Compute the top left cell coordinates and width and height of the
2692 # tile that covers the given extent.
2693 # @param e The extent whose tile is needed.
2694 # @note Requires that the raster is a strictly north up one.
2695 # @return A list ($xoff, $yoff, $xsize, $ysize).
2698 my ($self, $e) = @_;
2699 my ($w, $h) = $self->Size;
2700 my $t = $self->GeoTransform;
2701 confess
"GeoTransform is not \"north up\"." unless $t->NorthUp;
2702 my $xoff = floor(($e->[0] - $t->[0])/$t->[1]);
2703 $xoff = 0
if $xoff < 0;
2704 my $yoff = floor(($e->[1] - $t->[3])/$t->[5]);
2705 $yoff = 0
if $yoff < 0;
2706 my $xsize = ceil(($e->[2] - $t->[0])/$t->[1]) - $xoff;
2707 $xsize = $w - $xoff
if $xsize > $w - $xoff;
2708 my $ysize = ceil(($e->[3] - $t->[3])/$t->[5]) - $yoff;
2709 $ysize = $h - $yoff
if $ysize > $h - $yoff;
2710 return ($xoff, $yoff, $xsize, $ysize);
2713 #** @method Geo::GDAL::Dataset Translate($Dest, hashref Options, coderef progress, $progress_data)
2715 # Convert this dataset into another format.
2716 # @param Dest Destination dataset definition string (typically
2717 # filename) or an object, which implements write and close.
2718 # @param Options See section \ref index_processing_options.
2719 # @return New dataset object if destination dataset definition
2720 # string was given, otherwise a boolean for success/fail but the
2721 # method croaks if there was an error.
2724 my ($self, $dest, $options, $progress, $progress_data) = @_;
2725 return $self->stdout_redirection_wrapper(
2729 #** @method Geo::GDAL::Dataset Warp($Dest, hashref Options, coderef progress, $progress_data)
2731 # Reproject this dataset.
2732 # @param Dest Destination raster dataset definition string (typically
2733 # filename) or an object, which implements write and close.
2734 # @param Options See section \ref index_processing_options.
2735 # @note This method can be run as a package subroutine with a list of
2736 # datasets as the first argument to mosaic several datasets.
2739 my ($self, $dest, $options, $progress, $progress_data) = @_;
2740 # can be run as object method (one dataset) and as package sub (a list of datasets)
2741 $options = Geo::GDAL::GDALWarpAppOptions->new(make_processing_options($options));
2742 my $b = blessed($dest);
2743 $self = [$self] unless ref $self eq
'ARRAY';
2744 if ($b && $b eq
'Geo::GDAL::Dataset') {
2745 Geo::GDAL::wrapper_GDALWarpDestDS($dest, $self, $options, $progress, $progress_data);
2747 return stdout_redirection_wrapper(
2750 \&Geo::GDAL::wrapper_GDALWarpDestName,
2751 $options, $progress, $progress_data
2756 #** @method Geo::GDAL::Dataset Warped(%params)
2758 # Create a virtual warped dataset from this dataset.
2760 # @param params Named parameters:
2761 # - \a SrcSRS Override the spatial reference system of this dataset if there is one (default is undef).
2762 # - \a DstSRS The target spatial reference system of the result (default is undef).
2763 # - \a ResampleAlg The resampling algorithm (default is 'NearestNeighbour').
2764 # - \a MaxError Maximum error measured in input cellsize that is allowed in approximating the transformation (default is 0 for exact calculations).
2766 # # <a href="http://www.gdal.org/gdalwarper_8h.html">Documentation for GDAL warper.</a>
2768 # @return a new Geo::GDAL::Dataset object
2772 my $p = named_parameters(\@_, SrcSRS => undef, DstSRS => undef, ResampleAlg =>
'NearestNeighbour', MaxError => 0);
2773 for my $srs (qw/srcsrs dstsrs/) {
2774 $p->{$srs} = $p->{$srs}->ExportToWkt
if $p->{$srs} && blessed $p->{$srs};
2776 $p->{resamplealg} = s2i(resampling => $p->{resamplealg});
2777 my $warped = Geo::GDAL::_AutoCreateWarpedVRT($self, $p->{srcsrs}, $p->{dstsrs}, $p->{resamplealg}, $p->{maxerror});
2778 keep($warped, $self)
if $warped; #
self must live as
long as warped
2781 #** @method WriteRaster(%params)
2783 # Write data into the dataset.
2785 # @param params Named parameters:
2786 # - \a XOff x offset (cell coordinates) (default is 0)
2787 # - \a YOff y offset (cell coordinates) (default is 0)
2788 # - \a XSize width of the area to write (default is the width of the dataset)
2789 # - \a YSize height of the area to write (default is the height of the dataset)
2790 # - \a Buf a buffer (or a reference to a buffer) containing the data. Create the buffer with \a pack function of Perl. See Geo::GDAL::Band::PackCharacter.
2791 # - \a BufXSize (default is undef, i.e., the same as XSize)
2792 # - \a BufYSize (default is undef, i.e., the same as YSize)
2793 # - \a BufType data type of the buffer (default is the data type of the first band)
2794 # - \a BandList a reference to an array of band indices (default is [1])
2795 # - \a BufPixelSpace (default is 0)
2796 # - \a BufLineSpace (default is 0)
2797 # - \a BufBandSpace (default is 0)
2799 # <a href="http://www.gdal.org/classGDALDataset.html">Entry in GDAL docs (method RasterIO)</a>
2803 my ($width, $height) = $self->Size;
2804 my ($type) = $self->Band->DataType;
2805 my $p = named_parameters(\@_,
2819 $p->{buftype} = s2i(data_type => $p->{buftype}, 1);
2820 $self->_WriteRaster($p->{xoff},$p->{yoff},$p->{xsize},$p->{ysize},$p->{buf},$p->{bufxsize},$p->{bufysize},$p->{buftype},$p->{bandlist},$p->{bufpixelspace},$p->{buflinespace},$p->{bufbandspace});
2823 #** @method WriteTile()
2826 my ($self, $data, $xoff, $yoff) = @_;
2829 for my $i (0..$self->Bands-1) {
2830 $self->Band($i+1)->WriteTile($data->[$i], $xoff, $yoff);
2834 #** @class Geo::GDAL::Dimension
2836 package Geo::GDAL::Dimension;
2840 #** @method GetDirection()
2845 #** @method GetFullName()
2850 #** @method GetIndexingVariable()
2852 sub GetIndexingVariable {
2855 #** @method GetName()
2860 #** @method GetSize()
2865 #** @method GetType()
2870 #** @method SetIndexingVariable()
2872 sub SetIndexingVariable {
2875 #** @class Geo::GDAL::Driver
2876 # @brief A driver for a specific dataset format.
2879 package Geo::GDAL::Driver;
2883 #** @attr $HelpTopic
2884 # $driver->{HelpTopic}
2888 # $driver->{LongName}
2891 #** @attr $ShortName
2892 # $driver->{ShortName}
2895 #** @method list Capabilities()
2897 # @return A list of capabilities. When executed as a package subroutine
2898 # returns a list of all potential capabilities a driver may have. When
2899 # executed as an object method returns a list of all capabilities the
2902 # Currently capabilities are:
2903 # COORDINATE_EPOCH, CREATE, CREATECOPY, CREATECOPY_MULTIDIMENSIONAL, CREATE_MULTIDIMENSIONAL, DEFAULT_FIELDS, FEATURE_STYLES, GNM, MULTIDIM_RASTER, MULTIPLE_VECTOR_LAYERS, NONSPATIAL, NOTNULL_FIELDS, NOTNULL_GEOMFIELDS, OPEN, RASTER, SUBCREATECOPY, UNIQUE_FIELDS, VECTOR, and VIRTUALIO.
2907 # @all_capabilities = Geo::GDAL::Driver::Capabilities;
2908 # @capabilities_of_the_geotiff_driver = Geo::GDAL::Driver('GTiff')->Capabilities;
2913 return @CAPABILITIES unless $self;
2914 my $h = $self->GetMetadata;
2916 for my $cap (@CAPABILITIES) {
2917 my $test = $h->{
'DCAP_'.uc($cap)};
2918 push @cap, $cap
if defined($test) and $test eq
'YES';
2923 #** @method Geo::GDAL::Dataset Copy(%params)
2925 # Create a new raster Geo::GDAL::Dataset as a copy of an existing dataset.
2926 # @note a.k.a. CreateCopy
2928 # @param params Named parameters:
2929 # - \a Name name for the new raster dataset.
2930 # - \a Src the source Geo::GDAL::Dataset object.
2931 # - \a Strict 1 (default) if the copy must be strictly equivalent, or 0 if the copy may adapt.
2932 # - \a Options an anonymous hash of driver specific options.
2933 # - \a Progress [optional] a reference to a subroutine, which will
2934 # be called with parameters (number progress, string msg, progress_data).
2935 # - \a ProgressData [optional]
2936 # @return a new Geo::GDAL::Dataset object.
2940 my $p = named_parameters(\@_, Name =>
'unnamed', Src => undef, Strict => 1, Options => {}, Progress => undef, ProgressData => undef);
2941 return $self->stdout_redirection_wrapper(
2943 $self->can(
'_CreateCopy'),
2944 $p->{src}, $p->{strict}, $p->{options}, $p->{progress}, $p->{progressdata});
2947 #** @method CopyFiles($NewName, $OldName)
2949 # Copy the files of a dataset.
2950 # @param NewName String.
2951 # @param OldName String.
2956 #** @method Geo::GDAL::Dataset Create(%params)
2958 # Create a raster dataset using this driver.
2959 # @note a.k.a. CreateDataset
2961 # @param params Named parameters:
2962 # - \a Name The name for the dataset (default is 'unnamed') or an object, which implements write and close.
2963 # - \a Width The width for the raster dataset (default is 256).
2964 # - \a Height The height for the raster dataset (default is 256).
2965 # - \a Bands The number of bands to create into the raster dataset (default is 1).
2966 # - \a Type The data type for the raster cells (default is 'Byte'). One of Geo::GDAL::Driver::CreationDataTypes.
2967 # - \a Options Driver creation options as a reference to a hash (default is {}).
2969 # @return A new Geo::GDAL::Dataset object.
2973 my $p = named_parameters(\@_, Name =>
'unnamed', Width => 256, Height => 256, Bands => 1, Type =>
'Byte', Options => {});
2974 my $type = s2i(data_type => $p->{type});
2975 return $self->stdout_redirection_wrapper(
2977 $self->can(
'_Create'),
2978 $p->{width}, $p->{height}, $p->{bands}, $type, $p->{options}
2982 #** @method CreateMultiDimensional()
2984 sub CreateMultiDimensional {
2987 #** @method list CreationDataTypes()
2989 # @return a list of data types that can be used for new datasets of this format. A subset of Geo::GDAL::DataTypes
2991 sub CreationDataTypes {
2993 my $h = $self->GetMetadata;
2994 return split /\s+/, $h->{DMD_CREATIONDATATYPES}
if $h->{DMD_CREATIONDATATYPES};
2997 #** @method list CreationOptionList()
2999 # @return a list of options, each option is a hashref, the keys are
3000 # name, type and description or Value. Value is a listref.
3002 sub CreationOptionList {
3005 my $h = $self->GetMetadata->{DMD_CREATIONOPTIONLIST};
3007 $h = ParseXMLString($h);
3008 my($type, $value) = NodeData($h);
3009 if ($value eq
'CreationOptionList') {
3010 for my $o (Children($h)) {
3012 for my $a (Children($o)) {
3013 my(undef, $key) = NodeData($a);
3014 my(undef, $value) = NodeData(Child($a, 0));
3015 if ($key eq
'Value') {
3016 push @{$option{$key}}, $value;
3018 $option{$key} = $value;
3021 push @options, \%option;
3028 #** @method Delete($name)
3035 #** @method Domains()
3041 #** @method scalar Extension()
3043 # @note The returned extension does not contain a '.' prefix.
3044 # @return a suggested single extension or a list of extensions (in
3045 # list context) for datasets.
3049 my $h = $self->GetMetadata;
3051 my $e = $h->{DMD_EXTENSIONS};
3052 my @e = split / /, $e;
3054 for my $i (0..$#e) {
3059 my $e = $h->{DMD_EXTENSION};
3060 return '' if $e =~ /\
3066 #** @method scalar MIMEType()
3068 # @return a suggested MIME type for datasets.
3072 my $h = $self->GetMetadata;
3073 return $h->{DMD_MIMETYPE};
3076 #** @method scalar Name()
3078 # @return The short name of the driver.
3082 return $self->{ShortName};
3087 # The same as Geo::GDAL::Open except that only this driver is allowed.
3091 my @p = @_; # name, update
3092 my @flags = qw/RASTER/;
3093 push @flags, qw/READONLY/
if $p[1] eq
'ReadOnly';
3094 push @flags, qw/UPDATE/
if $p[1] eq
'Update';
3095 my $dataset = OpenEx($p[0], \@flags, [$self->Name()]);
3096 error(
"Failed to open $p[0]. Is it a raster dataset?") unless $dataset;
3100 #** @method Rename($NewName, $OldName)
3102 # Rename (move) a GDAL dataset.
3103 # @param NewName String.
3104 # @param OldName String.
3109 #** @method scalar TestCapability($cap)
3111 # Test whether the driver has the specified capability.
3112 # @param cap A capability string (one of those returned by Capabilities).
3113 # @return a boolean value.
3115 sub TestCapability {
3116 my($self, $cap) = @_;
3117 my $h = $self->GetMetadata->{
'DCAP_'.uc($cap)};
3118 return (defined($h) and $h eq
'YES') ? 1 : undef;
3121 #** @method stdout_redirection_wrapper()
3123 sub stdout_redirection_wrapper {
3124 my ($self, $name, $sub, @params) = @_;
3126 if ($name && blessed $name) {
3128 my $ref = $object->can(
'write');
3129 VSIStdoutSetRedirection($ref);
3130 $name =
'/vsistdout/';
3134 $ds = $sub->($self, $name, @params);
3138 $Geo::GDAL::stdout_redirection{tied(%$ds)} = $object;
3140 VSIStdoutUnsetRedirection();
3144 confess(last_error()) if $@;
3145 confess("Failed. Use Geo::OGR::Driver for vector drivers.") unless $ds;
3149 #** @class Geo::GDAL::EDTComponent
3151 package Geo::GDAL::EDTComponent;
3155 #** @method GetName()
3160 #** @method GetOffset()
3165 #** @method GetType()
3170 #** @class Geo::GDAL::ExtendedDataType
3172 package Geo::GDAL::ExtendedDataType;
3176 #** @method CanConvertTo()
3181 #** @method CreateString()
3186 #** @method Equals()
3191 #** @method GetClass()
3196 #** @method GetMaxStringLength()
3198 sub GetMaxStringLength {
3201 #** @method GetName()
3206 #** @method GetNumericDataType()
3208 sub GetNumericDataType {
3211 #** @method GetSize()
3216 #** @method GetSubType()
3221 #** @class Geo::GDAL::Extent
3222 # @brief A rectangular area in projection coordinates: xmin, ymin, xmax, ymax.
3224 package Geo::GDAL::Extent;
3226 #** @method ExpandToInclude($extent)
3227 # Package subroutine.
3228 # Extends this extent to include the other extent.
3229 # @param extent Another Geo::GDAL::Extent object.
3231 sub ExpandToInclude {
3232 my ($self, $e) = @_;
3233 return if $e->IsEmpty;
3234 if ($self->IsEmpty) {
3237 $self->[0] = $e->[0]
if $e->[0] < $self->[0];
3238 $self->[1] = $e->[1]
if $e->[1] < $self->[1];
3239 $self->[2] = $e->[2]
if $e->[2] > $self->[2];
3240 $self->[3] = $e->[3]
if $e->[3] > $self->[3];
3244 #** @method IsEmpty()
3248 return $self->[2] < $self->[0];
3251 #** @method scalar Overlap($extent)
3252 # Package subroutine.
3253 # @param extent Another Geo::GDAL::Extent object.
3254 # @return A new, possibly empty, Geo::GDAL::Extent object, which
3255 # represents the joint area of the two extents.
3258 my ($self, $e) = @_;
3261 $ret->[0] = $e->[0]
if $self->[0] < $e->[0];
3262 $ret->[1] = $e->[1]
if $self->[1] < $e->[1];
3263 $ret->[2] = $e->[2]
if $self->[2] > $e->[2];
3264 $ret->[3] = $e->[3]
if $self->[3] > $e->[3];
3268 #** @method scalar Overlaps($extent)
3269 # Package subroutine.
3270 # @param extent Another Geo::GDAL::Extent object.
3271 # @return True if this extent overlaps the other extent, false otherwise.
3274 my ($self, $e) = @_;
3275 return $self->[0] < $e->[2] && $self->[2] > $e->[0] && $self->[1] < $e->[3] && $self->[3] > $e->[1];
3278 #** @method list Size()
3279 # Package subroutine.
3280 # @return A list ($width, $height).
3284 return (0,0)
if $self->
IsEmpty;
3285 return ($self->[2] - $self->[0], $self->[3] - $self->[1]);
3288 #** @method Geo::GDAL::Extent new(@params)
3289 # Package subroutine.
3290 # @param params nothing, a list ($xmin, $ymin, $xmax, $ymax), or an Extent object
3291 # @return A new Extent object (empty if no parameters, a copy of the parameter if it is an Extent object).
3298 } elsif (ref $_[0]) {
3303 bless $self, $class;
3307 #** @class Geo::GDAL::GCP
3308 # @brief A ground control point for georeferencing rasters.
3311 package Geo::GDAL::GCP;
3316 # cell x coordinate (access as $gcp->{Column})
3320 # unique identifier (string) (access as $gcp->{Id})
3324 # informational message (access as $gcp->{Info})
3328 # cell y coordinate (access as $gcp->{Row})
3332 # projection coordinate (access as $gcp->{X})
3336 # projection coordinate (access as $gcp->{Y})
3340 # projection coordinate (access as $gcp->{Z})
3343 #** @method scalar new($x = 0.0, $y = 0.0, $z = 0.0, $column = 0.0, $row = 0.0, $info = "", $id = "")
3345 # @param x projection coordinate
3346 # @param y projection coordinate
3347 # @param z projection coordinate
3348 # @param column cell x coordinate
3349 # @param row cell y coordinate
3350 # @param info informational message
3351 # @param id unique identifier (string)
3352 # @return a new Geo::GDAL::GCP object
3356 my $self = Geo::GDALc::new_GCP(@_);
3357 bless $self, $pkg
if defined($self);
3360 #** @class Geo::GDAL::GDALMultiDimInfoOptions
3362 package Geo::GDAL::GDALMultiDimInfoOptions;
3370 my $self = Geo::GDALc::new_GDALMultiDimInfoOptions(@_);
3371 bless $self, $pkg
if defined($self);
3374 #** @class Geo::GDAL::GDALMultiDimTranslateOptions
3376 package Geo::GDAL::GDALMultiDimTranslateOptions;
3384 my $self = Geo::GDALc::new_GDALMultiDimTranslateOptions(@_);
3385 bless $self, $pkg
if defined($self);
3388 #** @class Geo::GDAL::GeoTransform
3389 # @brief An array of affine transformation coefficients.
3390 # @details The geo transformation has the form
3392 # x = a + column * b + row * c
3393 # y = d + column * e + row * f
3396 # (column,row) is the location in cell coordinates, and
3397 # (x,y) is the location in projection coordinates, or vice versa.
3398 # A Geo::GDAL::GeoTransform object is a reference to an anonymous array [a,b,c,d,e,f].
3400 package Geo::GDAL::GeoTransform;
3402 #** @method Apply($x, $y)
3404 # @param x Column or x, or a reference to an array of columns or x's
3405 # @param y Row or y, or a reference to an array of rows or y's
3406 # @return a list (x, y), where x and y are the transformed coordinates
3407 # or references to arrays of transformed coordinates.
3410 my ($self, $columns, $rows) = @_;
3411 return Geo::GDAL::ApplyGeoTransform($self, $columns, $rows) unless ref($columns) eq
'ARRAY';
3413 for my $i (0..$#$columns) {
3415 Geo::GDAL::ApplyGeoTransform($self, $columns->[$i], $rows->[$i]);
3422 # @return a new Geo::GDAL::GeoTransform object, which is the inverse
3423 # of this one (in void context changes this object).
3427 my @inv = Geo::GDAL::InvGeoTransform($self);
3432 #** @method NorthUp()
3436 return $self->[2] == 0 && $self->[4] == 0;
3439 #** @method new(@params)
3441 # @param params nothing, a reference to an array [a,b,c,d,e,f], a list
3442 # (a,b,c,d,e,f), or named parameters
3443 # - \a GCPs A reference to an array of Geo::GDAL::GCP objects.
3444 # - \a ApproxOK Minimize the error in the coefficients (integer, default is 1 (true), used with GCPs).
3445 # - \a Extent A Geo::GDAL::Extent object used to obtain the coordinates of the up left corner position.
3446 # - \a CellSize The cell size (width and height) (default is 1, used with Extent).
3448 # @note When Extent is specified, the created geo transform will be
3449 # north up, have square cells, and coefficient f will be -1 times the
3450 # cell size (image y - row - will increase downwards and projection y
3451 # will increase upwards).
3452 # @return a new Geo::GDAL::GeoTransform object.
3458 $self = [0,1,0,0,0,1];
3459 } elsif (ref $_[0]) {
3461 } elsif ($_[0] =~ /^[a-zA-Z]/i) {
3462 my $p = named_parameters(\@_, GCPs => undef, ApproxOK => 1, Extent => undef, CellSize => 1);
3464 $self = Geo::GDAL::GCPsToGeoTransform($p->{gcps}, $p->{approxok});
3465 } elsif ($p->{extent}) {
3468 error(
"Missing GCPs or Extent");
3474 bless $self, $class;
3477 #** @class Geo::GDAL::Group
3479 package Geo::GDAL::Group;
3483 #** @method CreateAttribute()
3485 sub CreateAttribute {
3488 #** @method CreateDimension()
3490 sub CreateDimension {
3493 #** @method CreateGroup()
3498 #** @method GetAttribute()
3503 #** @method GetFullName()
3508 #** @method GetGroupNames()
3513 #** @method GetMDArrayNames()
3515 sub GetMDArrayNames {
3518 #** @method GetName()
3523 #** @method GetStructuralInfo()
3525 sub GetStructuralInfo {
3528 #** @method GetVectorLayerNames()
3530 sub GetVectorLayerNames {
3533 #** @method OpenGroup()
3538 #** @method OpenGroupFromFullname()
3540 sub OpenGroupFromFullname {
3543 #** @method OpenMDArray()
3548 #** @method OpenMDArrayFromFullname()
3550 sub OpenMDArrayFromFullname {
3553 #** @method OpenVectorLayer()
3555 sub OpenVectorLayer {
3558 #** @method ResolveMDArray()
3560 sub ResolveMDArray {
3563 #** @class Geo::GDAL::MDArray
3565 package Geo::GDAL::MDArray;
3569 #** @method AsClassicDataset()
3571 sub AsClassicDataset {
3579 #** @method ComputeStatistics()
3581 sub ComputeStatistics {
3584 #** @method CreateAttribute()
3586 sub CreateAttribute {
3589 #** @method DeleteNoDataValue()
3591 sub DeleteNoDataValue {
3594 #** @method GetAttribute()
3599 #** @method GetDataType()
3604 #** @method GetDimensionCount()
3606 sub GetDimensionCount {
3609 #** @method GetFullName()
3614 #** @method GetMask()
3619 #** @method GetName()
3624 #** @method GetNoDataValueAsDouble()
3626 sub GetNoDataValueAsDouble {
3629 #** @method GetNoDataValueAsString()
3631 sub GetNoDataValueAsString {
3634 #** @method GetOffset()
3639 #** @method GetOffsetStorageType()
3641 sub GetOffsetStorageType {
3644 #** @method GetScale()
3649 #** @method GetScaleStorageType()
3651 sub GetScaleStorageType {
3654 #** @method GetSpatialRef()
3659 #** @method GetStatistics()
3664 #** @method GetStructuralInfo()
3666 sub GetStructuralInfo {
3669 #** @method GetTotalElementsCount()
3671 sub GetTotalElementsCount {
3674 #** @method GetUnit()
3679 #** @method GetUnscaled()
3684 #** @method GetView()
3689 #** @method SetNoDataValueDouble()
3691 sub SetNoDataValueDouble {
3694 #** @method SetNoDataValueString()
3696 sub SetNoDataValueString {
3699 #** @method SetOffset()
3704 #** @method SetScale()
3709 #** @method SetSpatialRef()
3714 #** @method SetUnit()
3719 #** @method Transpose()
3724 #** @class Geo::GDAL::MajorObject
3725 # @brief An object, which holds meta data.
3728 package Geo::GDAL::MajorObject;
3732 #** @method scalar Description($description)
3734 # @param description [optional]
3735 # @return the description in a non-void context.
3738 my($self, $desc) = @_;
3739 SetDescription($self, $desc)
if defined $desc;
3740 GetDescription($self)
if defined wantarray;
3743 #** @method Domains()
3744 # Package subroutine.
3745 # @return the class specific DOMAINS list
3751 #** @method scalar GetDescription()
3755 sub GetDescription {
3758 #** @method hash reference GetMetadata($domain = "")
3760 # @note see Metadata
3767 #** @method GetMetadataDomainList()
3769 sub GetMetadataDomainList {
3772 #** @method hash reference Metadata(hashref metadata = undef, $domain = '')
3776 # @return the metadata in a non-void context.
3780 my $metadata = ref $_[0] ? shift : undef;
3782 SetMetadata($self, $metadata, $domain)
if defined $metadata;
3783 GetMetadata($self, $domain)
if defined wantarray;
3786 #** @method SetDescription($NewDesc)
3791 sub SetDescription {
3794 #** @method SetMetadata(hashref metadata, $domain = "")
3796 # @note see Metadata
3804 #** @class Geo::GDAL::RasterAttributeTable
3805 # @brief An attribute table in a raster band.
3808 package Geo::GDAL::RasterAttributeTable;
3819 #** @method ChangesAreWrittenToFile()
3821 sub ChangesAreWrittenToFile {
3824 #** @method Geo::GDAL::RasterAttributeTable Clone()
3826 # @return a new Geo::GDAL::RasterAttributeTable object
3831 #** @method hash Columns(%columns)
3833 # A get/set method for the columns of the RAT
3834 # @param columns optional, a the keys are column names and the values are anonymous
3835 # hashes with keys Type and Usage
3836 # @return a hash similar to the optional input parameter
3841 if (@_) { # create columns
3843 for my $name (keys %columns) {
3844 $self->CreateColumn($name, $columns{$name}{Type}, $columns{$name}{Usage});
3848 for my $c (0..$self->GetColumnCount-1) {
3849 my $name = $self->GetNameOfCol($c);
3850 $columns{$name}{Type} = $self->GetTypeOfCol($c);
3851 $columns{$name}{Usage} = $self->GetUsageOfCol($c);
3856 #** @method CreateColumn($name, $type, $usage)
3859 # @param type one of FieldTypes
3860 # @param usage one of FieldUsages
3863 my($self, $name, $type, $usage) = @_;
3864 for my $color (qw/Red Green Blue Alpha/) {
3865 carp
"RAT column type will be 'Integer' for usage '$color'." if $usage eq $color and $type ne
'Integer';
3867 $type = s2i(rat_field_type => $type);
3868 $usage = s2i(rat_field_usage => $usage);
3869 _CreateColumn($self, $name, $type, $usage);
3872 #** @method DumpReadable()
3877 #** @method list FieldTypes()
3878 # Package subroutine.
3882 return @FIELD_TYPES;
3885 #** @method list FieldUsages()
3886 # Package subroutine.
3890 return @FIELD_USAGES;
3893 #** @method scalar GetColOfUsage($usage)
3899 my($self, $usage) = @_;
3900 _GetColOfUsage($self, s2i(rat_field_usage => $usage));
3903 #** @method scalar GetColumnCount()
3907 sub GetColumnCount {
3910 #** @method scalar GetNameOfCol($column)
3918 #** @method scalar GetRowCount()
3924 #** @method scalar GetRowOfValue($value)
3926 # @param value a cell value
3927 # @return row index or -1
3932 #** @method GetTableType()
3937 #** @method scalar GetTypeOfCol($column)
3943 my($self, $col) = @_;
3944 i2s(rat_field_type => _GetTypeOfCol($self, $col));
3947 #** @method scalar GetUsageOfCol($column)
3953 my($self, $col) = @_;
3954 i2s(rat_field_usage => _GetUsageOfCol($self, $col));
3957 #** @method scalar GetValueAsDouble($row, $column)
3963 sub GetValueAsDouble {
3966 #** @method scalar GetValueAsInt($row, $column)
3975 #** @method scalar GetValueAsString($row, $column)
3981 sub GetValueAsString {
3984 #** @method LinearBinning($Row0MinIn, $BinSizeIn)
3986 # @param Row0MinIn [optional] the lower bound (cell value) of the first category.
3987 # @param BinSizeIn [optional] the width of each category (in cell value units).
3988 # @return ($Row0MinIn, $BinSizeIn) or an empty list if LinearBinning is not set.
3992 SetLinearBinning($self, @_)
if @_ > 0;
3993 return unless defined wantarray;
3994 my @a = GetLinearBinning($self);
3995 return $a[0] ? ($a[1], $a[2]) : ();
3998 #** @method SetRowCount($count)
4006 #** @method SetTableType()
4011 #** @method SetValueAsDouble($row, $column, $value)
4018 sub SetValueAsDouble {
4021 #** @method SetValueAsInt($row, $column, $value)
4031 #** @method SetValueAsString($row, $column, $value)
4038 sub SetValueAsString {
4041 #** @method scalar Value($row, $column, $value)
4045 # @param value [optional]
4049 my($self, $row, $column) = @_;
4050 SetValueAsString($self, $row, $column, $_[3])
if defined $_[3];
4051 return unless defined wantarray;
4052 GetValueAsString($self, $row, $column);
4055 #** @method Geo::GDAL::RasterAttributeTable new()
4057 # @return a new Geo::GDAL::RasterAttributeTable object
4061 my $self = Geo::GDALc::new_RasterAttributeTable(@_);
4062 bless $self, $pkg
if defined($self);
4065 #** @class Geo::GDAL::Statistics
4067 package Geo::GDAL::Statistics;
4075 my $self = Geo::GDALc::new_Statistics(@_);
4076 bless $self, $pkg
if defined($self);
4079 #** @class Geo::GDAL::Transformer
4081 # @details This class is not yet documented for the GDAL Perl bindings.
4082 # @todo Test and document.
4084 package Geo::GDAL::Transformer;
4088 #** @method TransformGeolocations()
4090 sub TransformGeolocations {
4093 #** @method TransformPoint()
4095 sub TransformPoint {
4102 my $self = Geo::GDALc::new_Transformer(@_);
4103 bless $self, $pkg
if defined($self);
4106 #** @class Geo::GDAL::VSIF
4107 # @brief A GDAL virtual file system.
4110 package Geo::GDAL::VSIF;
4112 use base qw(Exporter)
4119 Geo::GDAL::VSIFCloseL($self);
4129 #** @method MkDir($path)
4130 # Package subroutine.
4132 # @param path The directory to make.
4133 # @note The name of this method is VSIMkdir in GDAL.
4137 # mode unused in CPL
4138 Geo::GDAL::Mkdir($path, 0);
4141 #** @method Geo::GDAL::VSIF Open($filename, $mode)
4142 # Package subroutine.
4143 # @param filename Name of the file to open. For example "/vsimem/x".
4144 # @param mode Access mode. 'r', 'r+', 'w', etc.
4145 # @return A file handle on success.
4148 my ($path, $mode) = @_;
4149 my $self = Geo::GDAL::VSIFOpenL($path, $mode);
4150 bless $self,
'Geo::GDAL::VSIF';
4153 #** @method scalar Read($count)
4155 # @param count The number of bytes to read from the file.
4156 # @return A byte string.
4159 my ($self, $count) = @_;
4160 Geo::GDAL::VSIFReadL($count, $self);
4163 #** @method list ReadDir($dir)
4164 # Package subroutine.
4165 # @return Contents of a directory in an anonymous array or as a list.
4169 Geo::GDAL::ReadDir($path);
4172 #** @method scalar ReadDirRecursive($dir)
4173 # Package subroutine.
4174 # @note Give the directory in the form '/vsimem', i.e., without trailing '/'.
4175 # @return Contents of a directory tree in an anonymous array.
4177 sub ReadDirRecursive {
4179 Geo::GDAL::ReadDirRecursive($path);
4182 #** @method Rename($old, $new)
4183 # Package subroutine.
4185 # @note The name of this method is VSIRename in GDAL.
4188 my ($old, $new) = @_;
4189 Geo::GDAL::Rename($old, $new);
4192 #** @method RmDir($path)
4193 # Package subroutine.
4194 # Remove a directory.
4195 # @note The name of this method is VSIRmdir in GDAL.
4198 my ($dirname, $recursive) = @_;
4201 Geo::GDAL::Rmdir($dirname);
4203 for my $f (ReadDir($dirname)) {
4204 next
if $f eq
'..' or $f eq
'.';
4205 my @s = Stat($dirname.
'/'.$f);
4207 Unlink($dirname.
'/'.$f);
4208 } elsif ($s[0] eq
'd') {
4209 Rmdir($dirname.
'/'.$f, 1);
4210 Rmdir($dirname.
'/'.$f);
4217 my $r = $recursive ?
' recursively' :
'';
4218 error(
"Cannot remove directory \"$dirname\"$r.");
4222 #** @method Seek($offset, $whence)
4226 my ($self, $offset, $whence) = @_;
4227 Geo::GDAL::VSIFSeekL($self, $offset, $whence);
4230 #** @method list Stat($filename)
4231 # Package subroutine.
4232 # @return ($filemode, $filesize). filemode is f for a plain file, d
4233 # for a directory, l for a symbolic link, p for a named pipe (FIFO), S
4234 # for a socket, b for a block special file, and c for a character
4239 Geo::GDAL::Stat($path);
4242 #** @method scalar Tell()
4247 Geo::GDAL::VSIFTellL($self);
4250 #** @method Truncate($new_size)
4254 my ($self, $new_size) = @_;
4255 Geo::GDAL::VSIFTruncateL($self, $new_size);
4258 #** @method Unlink($filename)
4259 # Package subroutine.
4260 # @param filename The file to delete.
4261 # @return 0 on success and -1 on an error.
4264 my ($filename) = @_;
4265 Geo::GDAL::Unlink($filename);
4268 #** @method Write($scalar)
4270 # @param scalar The byte string to write to the file.
4271 # @return Number of bytes written into the file.
4274 my ($self, $data) = @_;
4275 Geo::GDAL::VSIFWriteL($data, $self);
4278 #** @class Geo::GDAL::VSILFILE
4280 package Geo::GDAL::VSILFILE;
4284 #** @class Geo::GDAL::XML
4285 # @brief A simple XML parser
4288 package Geo::GDAL::XML;
4290 #** @method new($string)
4292 # @param string String containing XML.
4293 # @return A new Geo::GDAL::XML object, which is a reference to an anonymous array.
4298 my $self = ParseXMLString($xml);
4299 bless $self, $class;
4300 $self->traverse(sub {my $node = shift; bless $node, $class});
4304 #** @method serialize()
4306 # @return The XML serialized into a string.
4310 return SerializeXMLTree($self);
4313 # This file was automatically generated by SWIG (http:
4316 # Do not make changes to this file unless you know what you are doing--modify
4317 # the SWIG interface file instead.
4320 #** @method traverse(coderef subroutine)
4322 # @param subroutine Code reference, which will be called for each node in the XML with parameters: node, node_type, node_value. Node type is either Attribute, Comment, Element, Literal, or Text.
4325 my ($self, $sub) = @_;
4326 my $type = $self->[0];
4327 my $data = $self->[1];
4328 $type = NodeType($type);
4329 $sub->($self, $type, $data);
4330 for my $child (@{$self}[2..$#$self]) {
4331 traverse($child, $sub);
4336 # @brief Base class for geographical networks in GDAL.
4341 #** @method CastToGenericNetwork()
4343 sub CastToGenericNetwork {
4346 #** @method CastToNetwork()
4351 #** @method GATConnectedComponents()
4353 sub GATConnectedComponents {
4356 #** @method GATDijkstraShortestPath()
4358 sub GATDijkstraShortestPath {
4361 #** @method GATKShortestPath()
4363 sub GATKShortestPath {
4366 #** @method GNM_EDGE_DIR_BOTH()
4368 sub GNM_EDGE_DIR_BOTH {
4371 #** @method GNM_EDGE_DIR_SRCTOTGT()
4373 sub GNM_EDGE_DIR_SRCTOTGT {
4376 #** @method GNM_EDGE_DIR_TGTTOSRC()
4378 sub GNM_EDGE_DIR_TGTTOSRC {
4382 #** @class Geo::GNM::GenericNetwork
4385 package Geo::GNM::GenericNetwork;
4389 #** @method ChangeAllBlockState()
4391 sub ChangeAllBlockState {
4394 #** @method ChangeBlockState()
4396 sub ChangeBlockState {
4399 #** @method ConnectFeatures()
4401 sub ConnectFeatures {
4404 #** @method ConnectPointsByLines()
4406 sub ConnectPointsByLines {
4409 #** @method CreateRule()
4414 #** @method DeleteAllRules()
4416 sub DeleteAllRules {
4419 #** @method DeleteRule()
4424 #** @method DisconnectFeatures()
4426 sub DisconnectFeatures {
4429 #** @method DisconnectFeaturesWithId()
4431 sub DisconnectFeaturesWithId {
4434 #** @method GetRules()
4439 #** @method ReconnectFeatures()
4441 sub ReconnectFeatures {
4444 #** @class Geo::GNM::MajorObject
4447 package Geo::GNM::MajorObject;
4449 #** @class Geo::GNM::Network
4452 package Geo::GNM::Network;
4456 #** @method CommitTransaction()
4458 sub CommitTransaction {
4461 #** @method CopyLayer()
4466 #** @method DisconnectAll()
4471 #** @method GetFeatureByGlobalFID()
4473 sub GetFeatureByGlobalFID {
4476 #** @method GetFileList()
4481 #** @method GetLayerByIndex()
4483 sub GetLayerByIndex {
4486 #** @method GetLayerByName()
4488 sub GetLayerByName {
4491 #** @method GetLayerCount()
4496 #** @method GetName()
4501 #** @method GetPath()
4506 #** @method GetProjection()
4511 #** @method GetProjectionRef()
4513 sub GetProjectionRef {
4516 #** @method GetVersion()
4521 #** @method RollbackTransaction()
4523 sub RollbackTransaction {
4526 #** @method StartTransaction()
4528 sub StartTransaction {
4532 # @brief OGR utility functions.
4533 # @details A wrapper for many OGR utility functions and a root class for all
4538 #** @method list ByteOrders()
4539 # Package subroutine.
4540 # @return a list of byte order types, XDR and NDR. XDR denotes
4541 # big-endian and NDR denotes little-endian.
4546 #** @method CreateGeometryFromEsriJson()
4548 sub CreateGeometryFromEsriJson {
4551 #** @method CreateGlobFieldDomain()
4553 sub CreateGlobFieldDomain {
4556 #** @method CreateRangeFieldDomain()
4558 sub CreateRangeFieldDomain {
4561 #** @method Geo::GDAL::Driver Driver($name)
4562 # Package subroutine.
4564 # @param name the short name of the driver.
4565 # @note No check is made that the driver is actually a vector driver.
4566 # @return a Geo::GDAL::Driver object.
4569 return 'Geo::GDAL::Driver' unless @_;
4573 #** @method list DriverNames()
4574 # Package subroutine.
4575 # A.k.a GetDriverNames
4577 # perl -MGeo::GDAL -e '@d=Geo::OGR::DriverNames;print "@d\n"'
4579 # @note Use Geo::GDAL::DriverNames for raster drivers.
4580 # @return a list of the short names of all available GDAL vector drivers.
4585 #** @method list Drivers()
4586 # Package subroutine.
4587 # @note Use Geo::GDAL::Drivers for raster drivers.
4588 # @return a list of all available GDAL vector drivers.
4592 for my $i (0..GetDriverCount()-1) {
4593 my $driver = Geo::GDAL::GetDriver($i);
4594 push @drivers, $driver
if $driver->TestCapability(
'VECTOR');
4599 #** @method Flatten()
4604 #** @method scalar GeometryTypeModify($type, $modifier)
4606 # @param type a geometry type (one of Geo::OGR::GeometryTypes).
4607 # @param modifier one of 'flatten', 'set_Z', 'make_collection', 'make_curve', or 'make_linear'.
4608 # @return modified geometry type.
4610 sub GeometryTypeModify {
4611 my($type, $modifier) = @_;
4612 $type = s2i(geometry_type => $type);
4613 return i2s(geometry_type => GT_Flatten($type))
if $modifier =~ /flat/i;
4614 return i2s(geometry_type => GT_SetZ($type))
if $modifier =~ /z/i;
4615 return i2s(geometry_type => GT_GetCollection($type))
if $modifier =~ /collection/i;
4616 return i2s(geometry_type => GT_GetCurve($type))
if $modifier =~ /curve/i;
4617 return i2s(geometry_type => GT_GetLinear($type))
if $modifier =~ /linear/i;
4618 error(1, $modifier, {Flatten => 1, SetZ => 1, GetCollection => 1, GetCurve => 1, GetLinear => 1});
4621 #** @method scalar GeometryTypeTest($type, $test, $type2)
4623 # @param type a geometry type (one of Geo::OGR::GeometryTypes).
4624 # @param test one of 'has_z', 'is_subclass_of', 'is_curve', 'is_surface', or 'is_non_linear'.
4625 # @param type2 a geometry type (one of Geo::OGR::GeometryTypes). Required for 'is_subclass_of' test.
4626 # @return result of the test.
4628 sub GeometryTypeTest {
4629 my($type, $test, $type2) = @_;
4630 $type = s2i(geometry_type => $type);
4631 if (defined $type2) {
4632 $type = s2i(geometry_type => $type);
4634 error(
"Usage: GeometryTypeTest(type1, 'is_subclass_of', type2).") if $test =~ /subclass/i;
4636 return GT_HasZ($type) if $test =~ /z/i;
4637 return GT_IsSubClassOf($type, $type2) if $test =~ /subclass/i;
4638 return GT_IsCurve($type) if $test =~ /curve/i;
4639 return GT_IsSurface($type) if $test =~ /surface/i;
4640 return GT_IsNonLinear($type) if $test =~ /linear/i;
4641 error(1, $test, {HasZ => 1, IsSubClassOf => 1, IsCurve => 1, IsSurface => 1, IsNonLinear => 1});
4644 #** @method list GeometryTypes()
4645 # Package subroutine.
4646 # @return a list of all geometry types, currently:
4647 # CircularString, CircularStringM, CircularStringZ, CircularStringZM, CompoundCurve, CompoundCurveM, CompoundCurveZ, CompoundCurveZM, Curve, CurveM, CurvePolygon, CurvePolygonM, CurvePolygonZ, CurvePolygonZM, CurveZ, CurveZM, GeometryCollection, GeometryCollection25D, GeometryCollectionM, GeometryCollectionZM, LineString, LineString25D, LineStringM, LineStringZM, LinearRing, MultiCurve, MultiCurveM, MultiCurveZ, MultiCurveZM, MultiLineString, MultiLineString25D, MultiLineStringM, MultiLineStringZM, MultiPoint, MultiPoint25D, MultiPointM, MultiPointZM, MultiPolygon, MultiPolygon25D, MultiPolygonM, MultiPolygonZM, MultiSurface, MultiSurfaceM, MultiSurfaceZ, MultiSurfaceZM, None, Point, Point25D, PointM, PointZM, Polygon, Polygon25D, PolygonM, PolygonZM, PolyhedralSurface, PolyhedralSurfaceM, PolyhedralSurfaceZ, PolyhedralSurfaceZM, Surface, SurfaceM, SurfaceZ, SurfaceZM, TIN, TINM, TINZ, TINZM, Triangle, TriangleM, TriangleZ, TriangleZM, and Unknown.
4651 # This file was automatically generated by SWIG (http:
4654 # Do not make changes to this file unless you know what you are doing--modify
4655 # the SWIG interface file instead.
4658 #** @method GetGEOSVersionMajor()
4660 sub GetGEOSVersionMajor {
4663 #** @method GetGEOSVersionMicro()
4665 sub GetGEOSVersionMicro {
4668 #** @method GetGEOSVersionMinor()
4670 sub GetGEOSVersionMinor {
4673 #** @method GetNonLinearGeometriesEnabledFlag()
4675 sub GetNonLinearGeometriesEnabledFlag {
4678 #** @method GetOpenDSCount()
4680 sub GetOpenDSCount {
4693 #** @method OFDMP_DEFAULT_VALUE()
4695 sub OFDMP_DEFAULT_VALUE {
4698 #** @method OFDMP_GEOMETRY_WEIGHTED()
4700 sub OFDMP_GEOMETRY_WEIGHTED {
4703 #** @method OFDMP_SUM()
4708 #** @method OFDSP_DEFAULT_VALUE()
4710 sub OFDSP_DEFAULT_VALUE {
4713 #** @method OFDSP_DUPLICATE()
4715 sub OFDSP_DUPLICATE {
4718 #** @method OFDSP_GEOMETRY_RATIO()
4720 sub OFDSP_GEOMETRY_RATIO {
4723 #** @method OFDT_CODED()
4728 #** @method OFDT_GLOB()
4733 #** @method OFDT_RANGE()
4738 #** @method Geo::GDAL::Dataset Open($name, $update = 0)
4740 # Open a vector data source.
4741 # @param name The data source string (directory, filename, etc.).
4742 # @param update Whether to open the data source in update mode (default is not).
4743 # @return a new Geo::GDAL::Dataset object.
4746 my @p = @_; # name, update
4747 my @flags = qw/VECTOR/;
4748 push @flags, qw/UPDATE/
if $p[1];
4750 error(
"Failed to open $p[0]. Is it a vector dataset?") unless $dataset;
4754 #** @method Geo::GDAL::Dataset OpenShared($name, $update = 0)
4756 # Open a vector data source in shared mode.
4757 # @param name The data source string (directory, filename, etc.).
4758 # @param update Whether to open the data source in update mode.
4759 # @return a new Geo::GDAL::Dataset object.
4762 my @p = @_; # name, update
4763 my @flags = qw/VECTOR SHARED/;
4764 push @flags, qw/UPDATE/
if $p[1];
4766 error(
"Failed to open $p[0]. Is it a vector dataset?") unless $dataset;
4770 #** @method SetGenerate_DB2_V72_BYTE_ORDER($Generate_DB2_V72_BYTE_ORDER)
4772 # Needed only on IBM DB2.
4774 sub SetGenerate_DB2_V72_BYTE_ORDER {
4777 #** @method SetNonLinearGeometriesEnabledFlag()
4779 sub SetNonLinearGeometriesEnabledFlag {
4782 #** @class Geo::OGR::DataSource
4783 # @brief A vector dataset.
4784 # @details This is a legacy class which should not be
4785 # used in new code. Use Geo::GDAL::Dataset.
4787 package Geo::OGR::DataSource;
4789 #** @method Geo::GDAL::Dataset Open()
4790 # Package subroutine.
4791 # The same as Geo::OGR::Open
4796 #** @method Geo::GDAL::Dataset OpenShared()
4797 # Package subroutine.
4798 # The same as Geo::OGR::OpenShared
4803 #** @class Geo::OGR::Driver
4804 # @brief A vector format driver.
4805 # @details This is a legacy class which
4806 # should not be used in new code. Use Geo::GDAL::Driver.
4808 package Geo::OGR::Driver;
4812 #** @method Geo::GDAL::Dataset Copy(Geo::GDAL::Dataset source, $name, arrayref options = undef)
4814 # Copy a vector data source into a new data source with this driver.
4815 # @param source The Geo::GDAL::Dataset object to be copied.
4816 # @param name The name for the new data source.
4817 # @param options Driver specific options. In addition to options
4818 # specified in GDAL documentation the option STRICT can be set to 'NO'
4819 # for a more relaxed copy. Otherwise the STRICT is 'YES'.
4820 # @note The order of the first two parameters is different from that in Geo::GDAL::Driver::Copy.
4821 # @return a new Geo::GDAL::Dataset object.
4824 my ($self, @p) = @_; # src, name, options
4825 my $strict = 1; # the
default in bindings
4826 $strict = 0
if $p[2] && $p[2]->{STRICT} eq
'NO';
4827 $self->SUPER::Copy($p[1], $p[0], $strict, @{$p[2..4]}); # path, src, strict, options, cb, cb_data
4830 #** @method Geo::GDAL::Dataset Create($name, hashref options = undef )
4832 # Create a new vector data source using this driver.
4833 # @param name The data source name.
4834 # @param options Driver specific dataset creation options.
4837 my ($self, $name, $options) = @_; # name, options
4839 $self->SUPER::Create(Name => $name, Width => 0, Height => 0, Bands => 0, Type =>
'Byte', Options => $options);
4844 # The same as Geo::OGR::Open except that only this driver is allowed.
4848 my @p = @_; # name, update
4849 my @flags = qw/VECTOR/;
4850 push @flags, qw/UPDATE/
if $p[1];
4852 error(
"Failed to open $p[0]. Is it a vector dataset?") unless $dataset;
4856 #** @class Geo::OGR::Feature
4857 # @brief A collection of non-spatial and spatial attributes.
4858 # @details A feature is a collection of non-spatial and spatial attributes and
4859 # an id, which is a special attribute, and data records according to
4860 # this data model. Attributes are called fields and some fields are
4861 # spatial, i.e., their value is a geometry. Fields have at least a
4862 # name and a type. Features may exist within a layer or
4863 # separately. The data model of a feature is a definition object.
4865 package Geo::OGR::Feature;
4869 #** @method Geo::OGR::Feature Clone()
4871 # @return a new Geo::OGR::Feature object
4876 #** @method DumpReadable()
4878 # Write the contents of this feature to stdout.
4883 #** @method scalar Equal($feature)
4885 # @param feature a Geo::OGR::Feature object for comparison
4891 #** @method scalar FID($id)
4893 # @brief Get or set the id of this feature.
4894 # @param id [optional] the id to set for this feature.
4895 # @return integer the id of this feature.
4899 $self->SetFID($_[0])
if @_;
4900 return unless defined wantarray;
4904 #** @method Field($name, $value, ...)
4906 # @brief Get, set, or unset the field value.
4907 # @param name the name (or the index) of the field.
4908 # @param value a scalar, a list of scalars or a reference to a
4909 # list. If undef, the field is unset. If a scalar or a list of
4910 # scalars, the field is set from them.
4911 # @note Non-scalar fields (for example Date) can be set either from a
4912 # scalar, which is then assumed to be a string and parsed, or from a
4913 # list of values (for example year, month, day for Date).
4914 # @note Setting and getting Integer64 fields requires 'use bigint' if
4915 # \$Config{ivsize} is smaller than 8, i.e., in a 32 bit machine.
4916 # @return in non-void context the value of the field, which may be a
4917 # scalar or a list, depending on the field type. For unset fields the
4918 # undef value is returned.
4922 my $field = $self->GetFieldIndex(shift
4923 $self->SetField($field, @_)
if @_;
4924 $self->GetField($field)
if defined wantarray;
4927 #** @method FillUnsetWithDefault()
4929 sub FillUnsetWithDefault {
4932 #** @method Geometry($name, $geometry)
4934 # @brief Get or set the value of a geometry field.
4935 # @note This method delivers the functionality of undocumented methods
4936 # SetGeometry($geometry), SetGeometryDirectly, SetGeomField,
4937 # SetGeomFieldDirectly, GetGeometry, GetGeometryRef.
4939 # Set or get the geometry in the feature. When setting, does a check
4940 # against the schema (GeometryType) of the feature. If the parameter
4941 # is a geometry object, it is cloned.
4942 # @param name [optional] the name of the spatial field,
4943 # whose geometry is to be set. If not given, sets or gets the geometry
4944 # of the first (or the single) spatial field.
4945 # @param geometry [optional] a Geo::OGR::Geometry object or a
4946 # reference to a hash from which such can be created (using
4947 # Geo::OGR::Geometry::new).
4948 # @return in a non-void context the indicated geometry in the feature
4949 # as a Geo::OGR::Geometry object. The returned object contains a
4950 # reference to the actual geometry data in the feature (the geometry
4951 # is not cloned) and to the feature object, thus keeping the feature
4952 # object from being destroyed while the geometry object exists.
4956 my $field = ((@_ > 0 and ref($_[0]) eq
'') or (@_ > 2 and @_ % 2 == 1)) ? shift : 0;
4957 $field = $self->GetGeomFieldIndex($field);
4959 if (@_ and @_ % 2 == 0) {
4965 my $type = $self->GetDefn->GetGeomFieldDefn($field)->Type;
4966 if (blessed($geometry) and $geometry->isa(
'Geo::OGR::Geometry')) {
4967 my $gtype = $geometry->GeometryType;
4968 error(
"The type of the inserted geometry ('$gtype') is not the same as the type of the field ('$type').")
4969 if $type ne 'Unknown' and $type ne $gtype;
4971 $self->SetGeomFieldDirectly($field, $geometry->Clone);
4973 confess last_error() if $@;
4974 } elsif (ref($geometry) eq 'HASH') {
4975 $geometry->{GeometryType}
4979 confess last_error() if $@;
4980 my $gtype = $geometry->GeometryType;
4981 error("The type of the inserted geometry ('$gtype') is not the same as the type of the field ('$type').")
4982 if $type ne 'Unknown' and $type ne $gtype;
4984 $self->SetGeomFieldDirectly($field, $geometry);
4986 confess last_error() if $@;
4988 error(
"Usage: \$feature->Geometry([field],[geometry])");
4991 return unless defined wantarray;
4992 $geometry = $self->GetGeomFieldRef($field);
4993 return unless $geometry;
4994 keep($geometry, $self);
4997 #** @method Geo::OGR::FeatureDefn GetDefn()
4999 # @note A.k.a GetDefnRef.
5000 # @return a Geo::OGR::FeatureDefn object, which represents the definition of this feature.
5004 my $defn = $self->GetDefnRef;
5008 #** @method scalar GetFID()
5010 # @return the feature id (an integer).
5015 #** @method list GetField($name)
5020 my ($self, $field) = @_;
5021 $field = $self->GetFieldIndex($field);
5022 return unless IsFieldSet($self, $field);
5023 my $type = GetFieldType($self, $field);
5024 return GetFieldAsInteger($self, $field)
if $type == $Geo::OGR::OFTInteger;
5025 return GetFieldAsInteger64($self, $field)
if $type == $Geo::OGR::OFTInteger64;
5026 return GetFieldAsDouble($self, $field)
if $type == $Geo::OGR::OFTReal;
5027 return GetFieldAsString($self, $field)
if $type == $Geo::OGR::OFTString;
5028 if ($type == $Geo::OGR::OFTIntegerList) {
5029 my $ret = GetFieldAsIntegerList($self, $field);
5030 return wantarray ? @$ret : $ret;
5032 if ($type == $Geo::OGR::OFTInteger64List) {
5033 my $ret = GetFieldAsInteger64List($self, $field);
5034 return wantarray ? @$ret : $ret;
5036 if ($type == $Geo::OGR::OFTRealList) {
5037 my $ret = GetFieldAsDoubleList($self, $field);
5038 return wantarray ? @$ret : $ret;
5040 if ($type == $Geo::OGR::OFTStringList) {
5041 my $ret = GetFieldAsStringList($self, $field);
5042 return wantarray ? @$ret : $ret;
5044 if ($type == $Geo::OGR::OFTBinary) {
5045 return GetFieldAsBinary($self, $field);
5047 if ($type == $Geo::OGR::OFTDate) {
5048 my @ret = GetFieldAsDateTime($self, $field);
5049 # year, month, day, hour, minute, second, timezone
5050 return wantarray ? @ret[0..2] : [@ret[0..2]];
5052 if ($type == $Geo::OGR::OFTTime) {
5053 my @ret = GetFieldAsDateTime($self, $field);
5054 return wantarray ? @ret[3..6] : [@ret[3..6]];
5056 if ($type == $Geo::OGR::OFTDateTime) {
5057 my @ret = GetFieldAsDateTime($self, $field);
5058 return wantarray ? @ret : [@ret];
5060 error(
"Perl bindings do not support the field type '".i2s(field_type => $type).
"'.");
5063 #** @method scalar GetFieldDefn($name)
5065 # Get the definition of a field.
5066 # @param name the name of the field.
5067 # @return a Geo::OGR::FieldDefn object.
5071 my $field = $self->GetFieldIndex(shift);
5072 return $self->GetFieldDefnRef($field);
5075 #** @method list GetFieldNames()
5077 # Get the names of the fields in this feature.
5082 #** @method scalar GetGeomFieldDefn($name)
5084 # Get the definition of a spatial field.
5085 # @param name the name of the spatial field.
5086 # @return a Geo::OGR::GeomFieldDefn object.
5088 sub GetGeomFieldDefn {
5090 my $field = $self->GetGeomFieldIndex(shift);
5091 return $self->GetGeomFieldDefnRef($field);
5094 #** @method GetNativeData()
5099 #** @method GetNativeMediaType()
5101 sub GetNativeMediaType {
5104 #** @method hash reference GetSchema()
5106 # @brief Get the schema of this feature.
5108 # @return the schema as a hash whose keywords are Name, StyleIgnored
5109 # and Fields. Fields is an anonymous array of first non-spatial and
5110 # then spatial field schemas as in Geo::OGR::FieldDefn::Schema() and
5111 # Geo::OGR::GeomFieldDefn::Schema().
5115 error(
"Schema of a feature cannot be set directly.") if @_;
5116 return $self->GetDefnRef->Schema;
5119 #** @method scalar GetStyleString()
5123 sub GetStyleString {
5126 #** @method IsFieldNull()
5131 #** @method IsFieldSetAndNotNull()
5133 sub IsFieldSetAndNotNull {
5136 #** @method Geo::OGR::Layer Layer()
5138 # @return the layer to which this feature belongs to or undef.
5145 #** @method hash reference Row(%row)
5147 # @note This method discards the data the destination feature (or
5148 # layer) does not support. Changes in data due to differences between
5149 # field types may also occur.
5151 # Get and/or set the data of the feature. The key of the (key,value)
5152 # pairs of the row is the field name. Special field names FID and
5153 # Geometry are used for feature id and (single) geometry
5154 # respectively. The geometry/ies is/are set and get using the
5155 # Geo::OGR::Feature::Geometry method. Field values are set using the
5156 # Geo::OGR::Feature::Field method.
5157 # @param row [optional] feature data in a hash.
5158 # @return a reference to feature data in a hash. Spatial fields are
5159 # returned as Geo::OGR::Geometry objects.
5163 my $nf = $self->GetFieldCount;
5164 my $ngf = $self->GetGeomFieldCount;
5167 if (@_ == 1 and ref($_[0]) eq
'HASH') {
5169 } elsif (@_ and @_ % 2 == 0) {
5172 error(
'Usage: $feature->Row(%FeatureData).');
5174 $self->SetFID($row{FID})
if defined $row{FID};
5175 #$self->Geometry($schema, $row{Geometry}) if $row{Geometry};
5176 for my $name (keys %row) {
5177 next
if $name eq
'FID';
5178 if ($name eq
'Geometry') {
5179 $self->Geometry(0, $row{$name});
5183 for my $i (0..$nf-1) {
5184 if ($self->GetFieldDefnRef($i)->Name eq $name) {
5185 $self->SetField($i, $row{$name});
5191 for my $i (0..$ngf-1) {
5192 if ($self->GetGeomFieldDefnRef($i)->Name eq $name) {
5193 $self->Geometry($i, $row{$name});
5199 carp
"Unknown field: '$name'.";
5202 return unless defined wantarray;
5204 for my $i (0..$nf-1) {
5205 my $name = $self->GetFieldDefnRef($i)->Name;
5206 $row{$name} = $self->GetField($i);
5208 for my $i (0..$ngf-1) {
5209 my $name = $self->GetGeomFieldDefnRef($i)->Name ||
'Geometry';
5210 $row{$name} = $self->GetGeometry($i);
5212 $row{FID} = $self->GetFID;
5216 #** @method SetFID($id)
5218 # @param id the feature id.
5223 #** @method SetField($name, @Value)
5229 my $field = $self->GetFieldIndex(shift);
5231 if (@_ == 0 or !defined($arg)) {
5232 _UnsetField($self, $field);
5235 $arg = [@_]
if @_ > 1;
5236 my $type = $self->GetFieldType($field);
5238 if ($type == $Geo::OGR::OFTIntegerList) {
5239 SetFieldIntegerList($self, $field, $arg);
5241 elsif ($type == $Geo::OGR::OFTInteger64List) {
5242 SetFieldInteger64List($self, $field, $arg);
5244 elsif ($type == $Geo::OGR::OFTRealList) {
5245 SetFieldDoubleList($self, $field, $arg);
5247 elsif ($type == $Geo::OGR::OFTStringList) {
5248 SetFieldStringList($self, $field, $arg);
5250 elsif ($type == $Geo::OGR::OFTDate) {
5251 _SetField($self, $field, @$arg[0..2], 0, 0, 0, 0);
5253 elsif ($type == $Geo::OGR::OFTTime) {
5255 _SetField($self, $field, 0, 0, 0, @$arg[0..3]);
5257 elsif ($type == $Geo::OGR::OFTDateTime) {
5259 _SetField($self, $field, @$arg[0..6]);
5261 elsif ($type == $Geo::OGR::OFTInteger64)
5263 SetFieldInteger64($self, $field, $arg);
5266 $type = i2s(field_type => $type);
5267 my $name = $self->GetFieldDefnRef($field)->Name;
5268 error(
"'$arg' is not a suitable value for field $name($type).");
5271 if ($type == $Geo::OGR::OFTBinary) {
5272 #$arg = unpack('H*', $arg); # remove when SetFieldBinary is available
5273 $self->SetFieldBinary($field, $arg);
5275 elsif ($type == $Geo::OGR::OFTInteger64)
5277 SetFieldInteger64($self, $field, $arg);
5279 elsif ($type == $Geo::OGR::OFTInteger or $type == $Geo::OGR::OFTReal or $type == $Geo::OGR::OFTString)
5281 _SetField($self, $field, $arg);
5284 $type = i2s(field_type => $type);
5285 my $name = $self->GetFieldDefnRef($field)->Name;
5286 error(
"'$arg' is not a suitable value for field $name($type).");
5291 #** @method SetFieldNull()
5296 #** @method SetFrom($other, $forgiving = 1, hashref map)
5298 # @param other a Geo::OGR::Feature object
5299 # @param forgiving [optional] set to false if the operation should not
5300 # continue if output fields do not match some of the source fields
5301 # @param map [optional] a mapping from output field indexes to source
5302 # fields, include into the hash all field indexes of this feature
5303 # which should be set
5306 my($self, $other) = @_;
5307 _SetFrom($self, $other),
return if @_ <= 2;
5308 my $forgiving = $_[2];
5309 _SetFrom($self, $other, $forgiving),
return if @_ <= 3;
5312 for my $i (1..GetFieldCount($self)) {
5313 push @list, ($map->{$i} || -1);
5315 SetFromWithMap($self, $other, 1, \@list);
5318 #** @method SetNativeData()
5323 #** @method SetNativeMediaType()
5325 sub SetNativeMediaType {
5328 #** @method SetStyleString($string)
5332 sub SetStyleString {
5335 #** @method list Tuple(@tuple)
5337 # @note This method discards the data the destination feature (or
5338 # layer) does not support. Changes in data due to differences between
5339 # field types may also occur.
5341 # @note The schema of the tuple needs to be the same as that of the
5344 # Get and/set the data of the feature. The expected data in the tuple
5345 # is ([feature_id,] non-spatial fields, spatial fields). The fields in
5346 # the tuple are in the order they are in the schema. Field values are
5347 # set using the Geo::OGR::Feature::Field method. Geometries are set
5348 # and get using the Geo::OGR::Feature::Geometry method.
5349 # @param tuple [optional] feature data in an array
5350 # @return feature data in an array
5354 my $nf = $self->GetFieldCount;
5355 my $ngf = $self->GetGeomFieldCount;
5357 my $values = ref $_[0] ? $_[0] : \@_;
5359 $FID = shift @$values
if @$values == $nf + $ngf + 1;
5360 $self->SetFID($FID)
if defined $FID;
5361 if (@$values != $nf + $ngf) {
5363 error(
"Too many or too few attribute values for a feature (need $n).");
5365 my $index = 0; # index to non-geometry and geometry fields
5366 for my $i (0..$nf-1) {
5367 $self->SetField($i, $values->[$i]);
5369 for my $i (0..$ngf-1) {
5370 $self->Geometry($i, $values->[$nf+$i]);
5373 return unless defined wantarray;
5374 my @ret = ($self->GetFID);
5375 for my $i (0..$nf-1) {
5376 my $v = $self->GetField($i);
5379 for my $i (0..$ngf-1) {
5380 my $v = $self->GetGeometry($i);
5386 #** @method scalar Validate(list flags)
5388 # @param flags one of more of null, geom_type, width,
5389 # allow_null_when_default, or all.
5390 # @exception croaks with an error message if the feature is not valid.
5391 # @return integer denoting the validity of the feature object.
5397 my $f = eval
'$Geo::OGR::'.uc($flag);
5400 _Validate($self, $flags);
5403 #** @method Geo::OGR::Feature new(%schema)
5405 # @brief Create a new feature.
5406 # @param Named parameters:
5407 # - \a Schema a reference to a schema hash, or a Geo::OGR::Layer,
5408 # Geo::OGR::Feature, or Geo::OGR::FeatureDefn object.
5409 # - \a Values values for the feature attributes.
5410 # - \a StyleIgnored whether the style can be omitted when fetching
5411 # features. (default is false)
5413 # Schema is a hash with the following keys:
5414 # - \a Name name of the schema (not used).
5415 # - \a Fields a list of Geo::OGR::FieldDefn or Geo::OGR::GeomFieldDefn
5416 # objects or references to hashes from which fields can be created.
5417 # - \a GeometryType the geometry type if the feature has only one spatial field.
5419 # @note Do not mix GeometryType and geometry fields in Fields list.
5420 # @note Old syntax where the argument is a Geo::OGR::FeatureDefn
5421 # object or Schema hash is supported.
5423 # @return a new Geo::OGR::Feature object.
5429 if (ref $_[0] eq
'HASH' && $_[0]->{Schema}) {
5432 $arg = {Schema => $_[0]};
5434 } elsif (@_ and @_ % 2 == 0) {
5436 unless ($arg->{Schema}) {
5438 $arg->{Schema} = \%tmp;
5441 error(
"The argument must be either a schema or a hash.");
5443 error(
"Missing schema.") unless $arg->{Schema};
5445 for (ref $arg->{Schema}) {
5447 $defn = $arg->{Schema}->GetDefn;
5451 $defn = $arg->{Schema};
5456 my $self = Geo::OGRc::new_Feature($defn);
5457 error(
"Feature creation failed.") unless $self;
5459 for (ref $arg->{Values}) {
5461 $self->Tuple($arg->{Values});
5465 $self->Row($arg->{Values});
5469 $self->
Tuple($arg->{Values}->Tuple);
5475 error(
"Value parameter must be an array, hash, or another feature. Not $_.");
5480 #** @class Geo::OGR::FeatureDefn
5481 # @brief The schema of a feature or a layer.
5482 # @details A FeatureDefn object is a collection of field definition objects. A
5483 # read-only FeatureDefn object can be obtained from a layer
5484 # (Geo::OGR::Layer::GetDefn()) or a feature
5485 # (Geo::OGR::Feature::GetDefn()).
5487 package Geo::OGR::FeatureDefn;
5491 #** @method AddField(%params)
5493 # @param params Named parameters to create a new Geo::OGR::FieldDefn
5494 # or Geo::OGR::GeomFieldDefn object.
5498 error(
"Read-only definition.")
if parent($self);
5501 } elsif (ref($_[0]) eq
'HASH') {
5503 } elsif (@_ % 2 == 0) {
5507 if (s_exists(field_type => $params{Type})) {
5509 $self->AddFieldDefn($fd);
5512 $self->AddGeomFieldDefn($fd);
5516 #** @method DeleteField($name)
5518 # @note Currently only geometry fields can be deleted.
5519 # @param index the index of the geometry field to be deleted.
5522 my ($self, $name) = @_;
5523 error(
"Read-only definition.")
if parent($self);
5524 for my $i (0..$self->GetFieldCount-1) {
5525 error(
"Non-spatial fields cannot be deleted.")
if $self->_GetFieldDefn($i)->Name eq $name;
5527 for my $i (0..$self->GetGeomFieldCount-1) {
5528 $self->DeleteGeomFieldDefn($i)
if $self->_GetGeomFieldDefn($i)->Name eq $name;
5530 error(2, $name,
'Field');
5533 #** @method Feature()
5537 return parent($self);
5540 #** @method scalar GetFieldDefn($name)
5542 # Get the definition of a field.
5543 # @param name the name of the field.
5544 # @return a Geo::OGR::FieldDefn object.
5548 my $field = $self->GetFieldIndex(shift);
5549 return $self->_GetFieldDefn($field);
5552 #** @method list GetFieldNames()
5554 # The names of the fields in this layer or feature definition.
5555 # @return the list of field names.
5560 for my $i (0..$self->GetFieldCount-1) {
5561 push @names, $self->_GetFieldDefn($i)->Name;
5563 for my $i (0..$self->GetGeomFieldCount-1) {
5564 push @names, $self->_GetGeomFieldDefn($i)->Name;
5569 #** @method scalar GetGeomFieldDefn($name)
5571 # Get the definition of a spatial field.
5572 # @param name the name of the spatial field.
5573 # @return a Geo::OGR::GeomFieldDefn object.
5575 sub GetGeomFieldDefn {
5577 my $field = $self->GetGeomFieldIndex(shift);
5578 return $self->_GetGeomFieldDefn($field);
5581 #** @method scalar GetName()
5583 # @return the name of this layer or feature definition.
5588 #** @method hash reference GetSchema()
5590 # @brief Get the schema of this feature or layer definition.
5592 # @return the schema as a hash whose keywords are Name, StyleIgnored
5593 # and Fields. Fields is an anonymous array of first non-spatial and
5594 # then spatial field schemas as in Geo::OGR::FieldDefn::Schema() and
5595 # Geo::OGR::GeomFieldDefn::Schema().
5599 carp
"Schema of a feature definition should not be set directly." if @_;
5600 if (@_ and @_ % 2 == 0) {
5602 if ($schema{Fields}) {
5603 for my $field (@{$schema{Fields}}) {
5604 $self->AddField($field);
5609 $schema{Name} = $self->Name();
5610 $schema{StyleIgnored} = $self->StyleIgnored();
5611 $schema{Fields} = [];
5612 for my $i (0..$self->GetFieldCount-1) {
5613 my $s = $self->_GetFieldDefn($i)->Schema;
5614 push @{$schema{Fields}}, $s;
5616 for my $i (0..$self->GetGeomFieldCount-1) {
5617 my $s = $self->_GetGeomFieldDefn($i)->Schema;
5618 push @{$schema{Fields}}, $s;
5620 return wantarray ? %schema : \%schema;
5623 #** @method IsSame(Geo::OGR::FeatureDefn defn)
5625 # @return true if this definition is similar to the other definition,
5631 #** @method scalar IsStyleIgnored()
5633 # Get the ignore status of style information when fetching features.
5634 # @return the ignore status of style information
5637 sub IsStyleIgnored {
5640 #** @method SetStyleIgnored($IgnoreState)
5642 # Set the ignore status of style information when fetching features.
5645 sub SetStyleIgnored {
5648 #** @method Geo::OGR::FeatureDefn new(%schema)
5650 # Creates a new layer or feature definition. The new definition is
5651 # either initialized to the given schema or it will contain no
5652 # non-spatial fields and one spatial field, whose Name is '' and
5653 # GeometryType is 'Unknown' or the value of the named parameter
5655 # @param schema [optional] The schema for the new feature definition,
5656 # as in Geo::OGR::FeatureDefn::Schema().
5657 # @return a Geo::OGR::FeatureDefn object
5661 # $fd = Geo::OGR::FeatureDefn->new(
5663 # Fields => [{ Name => 'field1', Type => 'String' },
5664 # { Name => 'geom', GeometryType => 'Point' }] );
5670 if (@_ == 1 and ref($_[0]) eq
'HASH') {
5672 } elsif (@_ and @_ % 2 == 0) {
5675 my $fields = $schema{Fields};
5676 error(
"The 'Fields' argument must be an array reference.") if $fields and ref($fields) ne 'ARRAY';
5678 my $self = Geo::OGRc::new_FeatureDefn($schema{Name});
5680 my $gt = $schema{GeometryType};
5682 $self->GeometryType($gt);
5684 $self->DeleteGeomFieldDefn(0);
5686 $self->StyleIgnored($schema{StyleIgnored})
if exists $schema{StyleIgnored};
5687 for my $fd (@{$fields}) {
5689 if (ref($fd) eq
'HASH') {
5690 # if Name and Type are missing, assume Name => Type
5691 if (!(exists $fd->{Name} && exists $fd->{Type})) {
5692 for my $key (sort keys %$fd) {
5693 if (s_exists(field_type => $fd->{$key}) ||
5694 s_exists(geometry_type => $fd->{$key}))
5697 $fd->{Type} = $fd->{$key};
5703 if ($fd->{GeometryType} or ($fd->{Type} && s_exists(geometry_type => $fd->{Type}))) {
5709 if (blessed($d) and $d->isa(
'Geo::OGR::FieldDefn')) {
5710 AddFieldDefn($self, $d);
5711 } elsif (blessed($d) and $d->isa(
'Geo::OGR::GeomFieldDefn')) {
5712 error(
"Do not mix GeometryType and geometry fields in Fields.") if $gt;
5713 AddGeomFieldDefn($self, $d);
5715 error(
"Item in field list does not define a field.");
5721 #** @class Geo::OGR::FieldDefn
5722 # @brief A definition of a non-spatial attribute.
5725 package Geo::OGR::FieldDefn;
5729 #** @method scalar Default($value)
5731 # Get or set the default value for this field.
5732 # @note a.k.a. GetDefault and SetDefault
5733 # @param value [optional]
5734 # @return the default value of this field in non-void context.
5738 SetDefault($self, $_[0])
if @_;
5739 GetDefault($self)
if defined wantarray;
5742 #** @method GetAlternativeName()
5744 sub GetAlternativeName {
5747 #** @method GetAlternativeNameRef()
5749 sub GetAlternativeNameRef {
5752 #** @method GetDomainName()
5757 #** @method GetSchema()
5762 #** @method scalar Ignored($ignore)
5764 # Get and/or set the ignore status (whether this field should be
5765 # omitted when fetching features) of this field.
5766 # @note a.k.a. IsIgnored, SetIgnored
5767 # @param ignore [optional]
5768 # @return the ignore status of this field in non-void context.
5773 SetIgnored($self, $_[0])
if @_;
5774 IsIgnored($self)
if defined wantarray;
5777 #** @method IsDefaultDriverSpecific()
5779 sub IsDefaultDriverSpecific {
5782 #** @method IsUnique()
5787 #** @method scalar Justify($justify)
5789 # Get and/or set the justification of this field.
5790 # @note a.k.a. GetJustify, SetJustify
5791 # @param justify [optional] One of field justify types (Geo::OGR::FieldDefn::JustifyValues).
5792 # @return the justify value of this field in non-void context.
5795 my($self, $justify) = @_;
5796 if (defined $justify) {
5797 $justify = s2i(justify => $justify);
5798 SetJustify($self, $justify);
5800 return i2s(justify => GetJustify($self))
if defined wantarray;
5803 #** @method list JustifyValues()
5804 # Package subroutine.
5805 # Justify values supported by GDAL. Current list is
5806 # Left, Right, and Undefined.
5812 #** @method scalar Name($name)
5814 # Get and/or set the name of the field.
5815 # @note a.k.a. GetName, GetNameRef, SetName
5816 # @param name [optional]
5817 # @return the name in non-void context
5821 SetName($self, $_[0])
if @_;
5822 GetName($self)
if defined wantarray;
5825 #** @method scalar Nullable($nullable)
5827 # Get or set the nullable constraint for this field.
5828 # @note a.k.a. IsNullable and SetNullable
5829 # @param nullable [optional]
5830 # @return the nullable value of this field in non-void context.
5834 SetNullable($self, $_[0])
if @_;
5835 IsNullable($self)
if defined wantarray;
5838 #** @method scalar Precision($precision)
5840 # Get and/or set the precision of this field.
5841 # @note a.k.a. GetPrecision, SetPrecision
5842 # @param precision [optional]
5843 # @return the precision of this field in non-void context.
5847 SetPrecision($self, $_[0])
if @_;
5848 GetPrecision($self)
if defined wantarray;
5851 #** @method hash reference Schema(%params)
5853 # Get the schema or set parts of the schema
5854 # @param params [optional] as those in Geo::OGR::FieldDefn::new.
5855 # @return a reference to a hash whose keys are as those in Geo::OGR::FieldDefn::new.
5860 my $params = @_ % 2 == 0 ? {@_} : shift;
5861 for my $key (keys %SCHEMA_KEYS) {
5862 next unless exists $params->{$key};
5863 eval
"\$self->$key(\$params->{$key})";
5864 confess(last_error()) if $@;
5867 return unless defined wantarray;
5869 for my $key (keys %SCHEMA_KEYS) {
5870 $schema{$key} = eval
'$self->'.$key;
5872 return wantarray ? %schema : \%schema;
5875 #** @method SetAlternativeName()
5877 sub SetAlternativeName {
5880 #** @method SetDomainName()
5885 #** @method SetSchema()
5890 #** @method SetUnique()
5895 #** @method scalar SubType($SubType)
5897 # @note a.k.a. GetSubType, SetSubType
5898 # @param SubType [optional] One of field sub types (Geo::OGR::FieldDefn::SubTypes).
5899 # @return the sub type of this field in non-void context.
5902 my($self, $subtype) = @_;
5903 if (defined $subtype) {
5904 $subtype = s2i(field_subtype => $subtype);
5905 SetSubType($self, $subtype);
5907 return i2s(field_subtype => GetSubType($self))
if defined wantarray;
5910 #** @method SubTypes()
5916 #** @method scalar Type($type)
5918 # Get and/or set the type of the field.
5919 # @note a.k.a. GetFieldTypeName, GetTypeName, GetType, SetType
5920 # @param type [optional] One of field types (Geo::OGR::FieldDefn::Types).
5921 # @return one of field types in non-void context.
5924 my($self, $type) = @_;
5925 if (defined $type) {
5926 $type = s2i(field_type => $type);
5927 SetType($self, $type);
5929 return i2s(field_type => GetType($self))
if defined wantarray;
5932 #** @method list Types()
5933 # Package subroutine.
5934 # Field types supported by GDAL. Current list is
5935 # Binary, Date, DateTime, Integer, Integer64, Integer64List, IntegerList, Real, RealList, String, StringList, Time, WideString, and WideStringList.
5936 # (However, WideString is not supported.)
5942 #** @method scalar Width($width)
5944 # Get and/or set the field width.
5945 # @note a.k.a. GetWidth, SetWidth
5946 # @param width [optional]
5947 # @return the width of this field in non-void context.
5951 SetWidth($self, $_[0])
if @_;
5952 GetWidth($self)
if defined wantarray;
5955 #** @method Geo::OGR::FieldDefn new(%params)
5957 # @brief Create a new field definition.
5959 # @param Named parameters:
5960 # - \a Name Field name (default is 'unnamed').
5961 # - \a Type Field type, one of Geo::OGR::FieldDefn::Types (default is 'String').
5962 # - \a SubType Field sub type, one of Geo::OGR::FieldDefn::SubTypes.
5963 # - \a Justify Justify value, one of Geo::OGR::FieldDefn::JustifyValues
5966 # - \a Nullable (default is true)
5968 # - \a Ignored (default is false)
5970 # @note Simplified parameters Name => 'Type' are also supported.
5972 # @return a new Geo::OGR::FieldDefn object
5976 my $params = {Name =>
'unnamed', Type =>
'String'};
5978 } elsif (@_ == 1 and not ref $_[0]) {
5979 $params->{Name} = shift;
5980 } elsif (@_ == 2 and not $Geo::OGR::FieldDefn::SCHEMA_KEYS{$_[0]}) {
5981 $params->{Name} = shift;
5982 $params->{Type} = shift;
5984 my $tmp = @_ % 2 == 0 ? {@_} : shift;
5985 for my $key (keys %$tmp) {
5986 if ($Geo::OGR::FieldDefn::SCHEMA_KEYS{$key}) {
5987 $params->{$key} = $tmp->{$key};
5989 carp
"Unknown parameter: '$key'." if $key ne
'Index';
5993 $params->{Type} = s2i(field_type => $params->{Type});
5994 my $self = Geo::OGRc::new_FieldDefn($params->{Name}, $params->{Type});
5996 delete $params->{Name};
5997 delete $params->{Type};
5998 $self->Schema($params);
6002 #** @class Geo::OGR::FieldDomain
6004 package Geo::OGR::FieldDomain;
6008 #** @method GetDescription()
6010 sub GetDescription {
6013 #** @method GetDomainType()
6018 #** @method GetFieldSubType()
6020 sub GetFieldSubType {
6023 #** @method GetFieldType()
6028 #** @method GetGlob()
6033 #** @method GetMaxAsDouble()
6035 sub GetMaxAsDouble {
6038 #** @method GetMergePolicy()
6040 sub GetMergePolicy {
6043 #** @method GetMinAsDouble()
6045 sub GetMinAsDouble {
6048 #** @method GetName()
6053 #** @method GetSplitPolicy()
6055 sub GetSplitPolicy {
6058 #** @method IsMaxInclusive()
6060 sub IsMaxInclusive {
6063 #** @method IsMinInclusive()
6065 sub IsMinInclusive {
6068 #** @method SetMergePolicy()
6070 sub SetMergePolicy {
6073 #** @method SetSplitPolicy()
6075 sub SetSplitPolicy {
6078 #** @class Geo::OGR::GeomFieldDefn
6079 # @brief A definition of a spatial attribute.
6082 package Geo::OGR::GeomFieldDefn;
6086 #** @method scalar GeometryType($type)
6088 # @note a.k.a. GetType, SetType
6089 # @return the geometry type of the field.
6094 #** @method GetSchema()
6099 #** @method scalar Ignored($ignore)
6101 # @note a.k.a. IsIgnored, SetIgnored
6102 # @return the ignore status of the field.
6106 SetIgnored($self, $_[0])
if @_;
6107 IsIgnored($self)
if defined wantarray;
6110 #** @method scalar Name($name)
6112 # @note a.k.a. GetName, GetNameRef, SetName
6113 # @return the name of the field.
6117 SetName($self, $_[0])
if @_;
6118 GetName($self)
if defined wantarray;
6121 #** @method scalar Nullable($nullable)
6123 # @note a.k.a. IsNullable, SetNullable
6124 # @return the nullable status of the field.
6128 SetNullable($self, $_[0])
if @_;
6129 IsNullable($self)
if defined wantarray;
6132 #** @method hash reference Schema(%params)
6134 # Get the schema or set parts of the schema.
6135 # @param params [optional] as those in Geo::OGR::GeomFieldDefn::new.
6136 # @return a reference to a hash whose keys are as those in Geo::OGR::GeomFieldDefn::new.
6141 my $params = @_ % 2 == 0 ? {@_} : shift;
6142 for my $key (keys %SCHEMA_KEYS) {
6143 next unless exists $params->{$key};
6144 eval
"\$self->$key(\$params->{$key})";
6145 confess last_error() if $@;
6148 return unless defined wantarray;
6150 for my $key (keys %SCHEMA_KEYS) {
6151 $schema{$key} = eval
'$self->'.$key;
6153 return wantarray ? %schema : \%schema;
6156 #** @method SetSchema()
6161 #** @method scalar SpatialReference($sr)
6163 # @note a.k.a. GetSpatialRef, SetSpatialRef
6164 # @return the spatial reference of the field as a Geo::OSR::SpatialReference object.
6166 sub SpatialReference {
6168 SetSpatialRef($self, $_[0])
if @_;
6169 GetSpatialRef($self)
if defined wantarray;
6174 # @return the type of this geometry field. One of Geo::OGR::GeomFieldDefn::Types
6177 my($self, $type) = @_;
6178 if (defined $type) {
6179 $type = s2i(geometry_type => $type);
6180 SetType($self, $type);
6182 i2s(geometry_type => GetType($self))
if defined wantarray;
6186 # Package subroutine.
6187 # @return a list of all geometry types, currently:
6188 # CircularString, CircularStringM, CircularStringZ, CircularStringZM, CompoundCurve, CompoundCurveM, CompoundCurveZ, CompoundCurveZM, Curve, CurveM, CurvePolygon, CurvePolygonM, CurvePolygonZ, CurvePolygonZM, CurveZ, CurveZM, GeometryCollection, GeometryCollection25D, GeometryCollectionM, GeometryCollectionZM, LineString, LineString25D, LineStringM, LineStringZM, LinearRing, MultiCurve, MultiCurveM, MultiCurveZ, MultiCurveZM, MultiLineString, MultiLineString25D, MultiLineStringM, MultiLineStringZM, MultiPoint, MultiPoint25D, MultiPointM, MultiPointZM, MultiPolygon, MultiPolygon25D, MultiPolygonM, MultiPolygonZM, MultiSurface, MultiSurfaceM, MultiSurfaceZ, MultiSurfaceZM, None, Point, Point25D, PointM, PointZM, Polygon, Polygon25D, PolygonM, PolygonZM, PolyhedralSurface, PolyhedralSurfaceM, PolyhedralSurfaceZ, PolyhedralSurfaceZM, Surface, SurfaceM, SurfaceZ, SurfaceZM, TIN, TINM, TINZ, TINZM, Triangle, TriangleM, TriangleZ, TriangleZM, and Unknown.
6194 #** @method Geo::OGR::GeomFieldDefn new(%params)
6196 # @brief Create a new spatial field definition.
6198 # @param params one or more of:
6199 # - \a Name name for the field (default is 'geom').
6200 # - \a GeometryType type for the field type, one of Geo::OGR::GeomFieldDefn::Types (default is 'Unknown').
6201 # - \a SpatialReference a Geo::OSR::SpatialReference object.
6202 # - \a Nullable (default is true)
6203 # - \a Ignored (default is false)
6205 # @note Simplified parameters <name> => <type> is also supported.
6207 # @return a new Geo::OGR::GeomFieldDefn object
6211 my $params = {Name =>
'geom', Type =>
'Unknown'};
6214 $params->{Name} = shift;
6215 } elsif (@_ == 2 and not $Geo::OGR::GeomFieldDefn::SCHEMA_KEYS{$_[0]}) {
6216 $params->{Name} = shift;
6217 $params->{Type} = shift;
6219 my $tmp = @_ % 2 == 0 ? {@_} : shift;
6220 for my $key (keys %$tmp) {
6221 if ($Geo::OGR::GeomFieldDefn::SCHEMA_KEYS{$key}) {
6222 $params->{$key} = $tmp->{$key};
6224 carp
"Unknown parameter: '$key'." if $key ne
'Index' && $key ne
'GeometryType';
6229 $params->{Type} = s2i(geometry_type => $params->{Type});
6230 my $self = Geo::OGRc::new_GeomFieldDefn($params->{Name}, $params->{Type});
6232 delete $params->{Name};
6233 delete $params->{Type};
6234 $self->Schema($params);
6238 #** @class Geo::OGR::GeomTransformer
6240 package Geo::OGR::GeomTransformer;
6244 #** @method Transform()
6253 my $self = Geo::OGRc::new_GeomTransformer(@_);
6254 bless $self, $pkg
if defined($self);
6257 #** @class Geo::OGR::Geometry
6258 # @brief Spatial data.
6259 # @details A geometry is spatial data (coordinate values, and a reference to a
6260 # spatial reference system) organized into one of the geometry
6261 # types. Geometries can be created from several type of data including
6262 # a Perl data structure. There are several methods, which modify,
6263 # compare, test, or compute values from geometries.
6264 # @note Most spatial analysis methods require <a
6265 # href="http://geos.osgeo.org/doxygen/">GEOS</a> to work rigorously.
6267 package Geo::OGR::Geometry;
6271 #** @method AddGeometry($other)
6273 # Add a copy of another geometry to a geometry collection
6274 # @param other a Geo::OGR::Geometry object
6279 #** @method AddGeometryDirectly($other)
6281 # @param other a Geo::OGR::Geometry object
6283 sub AddGeometryDirectly {
6286 #** @method AddPoint($x, $y, $z)
6288 # Set the data of a point or add a point to a line string. Consider
6289 # using Geo::OGR::Geometry::Points. Note that the coordinate
6290 # dimension is automatically upgraded to 25D (3) if z is given.
6293 # @param z [optional]
6294 # Calls internally the 2D or 3D version depending on the number of parameters.
6298 my $t = $self->GetGeometryType;
6299 my $has_z = HasZ($t);
6300 my $has_m = HasM($t);
6301 if (!$has_z && !$has_m) {
6302 $self->AddPoint_2D(@_[0..1]);
6303 } elsif ($has_z && !$has_m) {
6304 $self->AddPoint_3D(@_[0..2]);
6305 } elsif (!$has_z && $has_m) {
6306 $self->AddPointM(@_[0..2]);
6308 $self->AddPointZM(@_[0..3]);
6312 #** @method AddPointM()
6317 #** @method AddPointZM()
6322 #** @method AddPoint_2D($x, $y)
6324 # Set the data of a point or add a point to a line string. Consider
6325 # using Geo::OGR::Geometry::Points.
6332 #** @method AddPoint_3D($x, $y, $z)
6334 # Set the data of a point or add a point to a line string. Note that
6335 # the coordinate dimension is automatically upgraded to 25D (3). Consider
6336 # using Geo::OGR::Geometry::Points.
6344 #** @method Geo::OGR::Geometry ApproximateArcAngles(%params)
6345 # Package subroutine.
6346 # Create a line string, which approximates an arc.
6347 # @note All angles are in degrees.
6349 # @param %params Named parameters:
6350 # - \a Center center point (default is [0, 0, 0])
6351 # - \a PrimaryRadius default is 1.
6352 # - \a SecondaryAxis default is 1.
6353 # - \a Rotation default is 0.
6354 # - \a StartAngle default is 0.
6355 # - \a EndAngle default is 360.
6356 # - \a MaxAngleStepSizeDegrees default is 4.
6357 # @return a new Geo::OGR::Geometry object.
6359 sub ApproximateArcAngles {
6361 my %
default = ( Center => [0,0,0],
6367 MaxAngleStepSizeDegrees => 4
6369 for my $p (keys %p) {
6370 if (exists $default{$p}) {
6373 carp
"Unknown parameter: '$p'.";
6376 for my $p (keys %
default) {
6379 error(
"Usage: Center => [x,y,z].") unless ref($p{Center}) eq
'ARRAY';
6383 return Geo::OGR::ApproximateArcAngles($p{Center}->[0], $p{Center}->[1], $p{Center}->[2], $p{PrimaryRadius}, $p{SecondaryAxis}, $p{Rotation}, $p{StartAngle}, $p{EndAngle}, $p{MaxAngleStepSizeDegrees});
6386 #** @method scalar Area()
6388 # @note a.k.a. GetArea
6389 # @return the area of the polygon or multipolygon
6394 #** @method scalar As(%params)
6396 # Export the geometry into a known format.
6398 # @param params Named parameters:
6399 # - \a Format One of
6400 # - \a WKT Well Known Text.
6401 # - <em>ISO WKT</em>
6402 # - \a Text Same as WKT.
6403 # - \a WKB Well Known Binary.
6404 # - <em>ISO WKB</em>
6405 # - \a Binary Same as WKB.
6410 # - \a ByteOrder Byte order for binary formats. Default is 'XDR'.
6411 # - \a SRID Spatial reference id for HEXEWKB.
6412 # - \a Options GML generation options.
6413 # - \a AltitudeMode For KML.
6415 # @return the geometry in a given format.
6419 my $p = named_parameters(\@_, Format => undef, ByteOrder =>
'XDR', SRID => undef, Options => undef, AltitudeMode => undef);
6420 my $f = $p->{format};
6421 if ($f =~ /text/i) {
6422 return $self->AsText;
6423 } elsif ($f =~ /wkt/i) {
6425 return $self->ExportToIsoWkt;
6427 return $self->AsText;
6429 } elsif ($f =~ /binary/i) {
6430 return $self->ExportToWkb($p->{byteorder});
6431 } elsif ($f =~ /wkb/i) {
6433 $p->{byteorder} = s2i(byte_order => $p->{byteorder});
6434 return $self->ExportToIsoWkb($p->{byteorder});
6435 } elsif ($f =~ /ewkb/i) {
6436 return $self->AsHEXEWKB($p->{srid});
6437 } elsif ($f =~ /hex/i) {
6438 return $self->AsHEXWKB;
6440 return $self->ExportToWkb($p->{byteorder});
6442 } elsif ($f =~ /gml/i) {
6443 return $self->ExportToGML($p->{options});
6444 } elsif ($f =~ /kml/i) {
6445 return $self->ExportToKML($p->{altitudemode});
6446 } elsif ($f =~ /json/i) {
6447 return $self->AsJSON;
6449 error(1, $f, map {$_=>1} qw/Text WKT ISO_WKT ISO_WKB HEX_WKB HEX_EWKB Binary GML KML JSON/);
6453 #** @method scalar AsBinary()
6455 # Export the geometry into WKB.
6456 # @sa Geo::OGR::Geometry::As
6457 # @return the geometry as WKB.
6462 #** @method scalar AsText()
6464 # Export the geometry into WKT.
6465 # @sa Geo::OGR::Geometry::As
6466 # @return the geometry as WKT.
6471 #** @method AssignSpatialReference($srs)
6473 # @param srs a Geo::OSR::SpatialReference object
6475 sub AssignSpatialReference {
6478 #** @method Geo::OGR::Geometry Boundary()
6480 # @note a.k.a. GetBoundary
6481 # @return the boundary of this geometry as a geometry
6487 #** @method Geo::OGR::Geometry Buffer($distance, $quadsecs = 30)
6491 # @return a new Geo::OGR::Geometry object
6496 #** @method Geo::OGR::Geometry BuildPolygonFromEdges($BestEffort = 0, $AutoClose = 0, $Tolerance = 0)
6498 # Attempt to create a polygon from a collection of lines or from a multilinestring.
6499 # @param BestEffort For future
6500 # @param AutoClose Assure the first and last points of rings are same.
6501 # @param Tolerance Snap distance.
6502 # @exception Several possibilities, some are reported, some are general errors.
6503 # @return a new Geo::OGR::Geometry object (Polygon)
6505 sub BuildPolygonFromEdges {
6508 #** @method list ByteOrders()
6509 # Package subroutine.
6510 # Same as Geo::OGR::ByteOrders
6513 return @BYTE_ORDER_TYPES;
6516 #** @method Geo::OGR::Geometry Centroid()
6518 # @return a new Geo::OGR::Geometry object
6524 #** @method Geo::OGR::Geometry Clone()
6526 # @return a new Geo::OGR::Geometry object
6531 #** @method CloseRings()
6537 #** @method Geo::OGR::Geometry Collect(@geometries)
6539 # Create a geometrycollection from this and possibly other geometries.
6540 # @param geometries [optional] More geometries to add to the collection.
6541 # @return a new Geo::OGR::Geometry object of type geometrycollection.
6546 #** @method scalar Contains($other)
6548 # @param other a Geo::OGR::Geometry object
6549 # @return true if this geometry contains the other geometry, false otherwise
6554 #** @method Geo::OGR::Geometry ConvexHull()
6556 # @return a new Geo::OGR::Geometry object
6561 #** @method scalar CoordinateDimension($dimension)
6563 # @param dimension [optional]
6566 sub CoordinateDimension {
6568 SetCoordinateDimension($self, $_[0])
if @_;
6569 GetCoordinateDimension($self)
if defined wantarray;
6572 #** @method CreatePreparedGeometry()
6574 sub CreatePreparedGeometry {
6577 #** @method scalar Crosses($other)
6579 # @param other a Geo::OGR::Geometry object
6580 # @return true if this geometry crosses the other geometry, false otherwise
6585 #** @method DelaunayTriangulation()
6587 sub DelaunayTriangulation {
6590 #** @method Geo::OGR::Geometry Difference($other)
6592 # @param other a Geo::OGR::Geometry object
6593 # @return a new Geo::OGR::Geometry object
6598 #** @method scalar Disjoint($other)
6600 # @param other a Geo::OGR::Geometry object
6601 # @return true if this geometry is disjoint from the other geometry, false otherwise
6606 #** @method list Dissolve()
6608 # Dissolve a geometrycollection into separate geometries.
6609 # @return a list of new Geo::OGR::Geometry objects cloned from the collection.
6614 my $n = $self->GetGeometryCount;
6616 for my $i (0..$n-1) {
6617 push @c, $self->GetGeometryRef($i)->Clone;
6625 #** @method scalar Distance($other)
6627 # @param other a Geo::OGR::Geometry object
6628 # @return the distance to the other geometry
6633 #** @method Distance3D()
6640 # Clear geometry data, i.e., remove all points, or, for a point, set
6641 # the coordinate dimension as zero.
6646 #** @method scalar Equals($other)
6648 # @note a.k.a. Equal (deprecated)
6649 # @param other a Geo::OGR::Geometry object
6650 # @return true if this geometry is equivalent to the other geometry, false otherwise
6655 #** @method Extent()
6662 #** @method Feature()
6669 #** @method FlattenTo2D()
6675 #** @method Geo::OGR::Geometry ForceTo($type, ref options)
6677 # Attempt to make a geometry of type 'type' out of this geometry.
6678 # @param type target geometry type. One of Geo::OGR::GeometryTypes.
6679 # @param options not used currently.
6680 # @return a new Geo::OGR::Geometry object.
6685 $type = s2i(geometry_type => $type);
6687 $self = Geo::OGR::ForceTo($self, $type, @_);
6689 confess last_error()
if $@;
6693 #** @method Geo::OGR::Geometry ForceToCollection(@geometries)
6695 # Create a geometrycollection from the geometry.
6696 # @param geometries [optional] More geometries to add to the collection.
6697 # @return a new Geo::OGR::Geometry object of type geometrycollection.
6699 sub ForceToCollection {
6707 #** @method Geo::OGR::Geometry ForceToLineString()
6709 # Attempt to create a line string from this geometry.
6710 # @return a new Geo::OGR::Geometry object.
6712 sub ForceToLineString {
6714 return Geo::OGR::ForceToLineString($self);
6717 #** @method Geo::OGR::Geometry ForceToMultiLineString(@linestrings)
6719 # Attempt to create a multilinestring from the geometry, which must be a linestring.
6720 # @param linestrings [optional] More linestrings to add to the collection.
6721 # @return a new Geo::OGR::Geometry object of type multilinestring.
6723 sub ForceToMultiLineString {
6725 $self = Geo::OGR::ForceToMultiLineString($self);
6727 $self->AddGeometry($g);
6732 #** @method Geo::OGR::Geometry ForceToMultiPoint(@points)
6734 # Attempt to create a multipoint from the geometry, which must be a point.
6735 # @param points [optional] More points to add to the collection.
6736 # @return a new Geo::OGR::Geometry object of type multipoint.
6738 sub ForceToMultiPoint {
6740 $self = Geo::OGR::ForceToMultiPoint($self);
6742 $self->AddGeometry($g);
6747 #** @method Geo::OGR::Geometry ForceToMultiPolygon(@polygons)
6749 # Attempt to create a multipolygon from the geometry, which must be a polygon.
6750 # @param polygons [optional] More polygons to add to the collection.
6751 # @return a new Geo::OGR::Geometry object of type multipolygon.
6753 sub ForceToMultiPolygon {
6755 $self = Geo::OGR::ForceToMultiPolygon($self);
6757 $self->AddGeometry($g);
6762 #** @method Geo::OGR::Geometry ForceToPolygon()
6764 # Attempt to create a polygon from this geometry.
6765 # @exception None reported. If this method fails, just a copy is returned.
6766 # @return a new Geo::OGR::Geometry object.
6768 sub ForceToPolygon {
6771 #** @method scalar Geometry($n)
6773 # Return the n:th (note zero-based index) element in this geometry or
6774 # geometry in this collection.
6775 # @note a.k.a. GetGeometryRef
6776 # @param n index to the geometry, which is a part of this geometry
6777 # @return a new Geo::OGR::Geometry object whose data is a part of the
6778 # parent geometry (this geometry is kept alive while the returned
6784 #** @method scalar GeometryCount()
6786 # Return the number of elements in this geometry or geometries in this collection.
6787 # @note a.k.a. GetGeometryCount
6788 # @return an integer
6793 #** @method scalar GeometryType()
6796 # @note The deprecated method GetGeometryType returns the
6797 # type as an integer
6799 # @return the geometry type of this geometry (one of Geo::OGR::GeometryTypes).
6803 return i2s(geometry_type => $self->GetGeometryType);
6806 #** @method list GeometryTypes()
6807 # Package subroutine.
6808 # Same as Geo::OGR::GeometryTypes
6811 return @GEOMETRY_TYPES;
6814 #** @method scalar GetCoordinateDimension()
6816 # @return an integer
6818 sub GetCoordinateDimension {
6821 #** @method GetCurveGeometry()
6823 sub GetCurveGeometry {
6826 #** @method scalar GetDimension()
6828 # @return 0, 1, or 2
6833 #** @method list GetEnvelope()
6835 # @note In scalar context returns a reference to an anonymous array
6836 # containing the envelope.
6837 # @return the envelope ($minx, $maxx, $miny, $maxy)
6842 #** @method list GetEnvelope3D()
6844 # @note In scalar context returns a reference to an anonymous array
6845 # containing the envelope.
6846 # @return the 3-D envelope ($minx, $maxx, $miny, $maxy, $minz, $maxz)
6852 #** @method scalar GetGeometryRef($index)
6854 # @deprecated Use Geo::OGR::Geometry
6856 sub GetGeometryRef {
6857 my ($self, $i) = @_;
6858 my $ref = $self->_GetGeometryRef($i);
6863 #** @method GetLinearGeometry()
6865 sub GetLinearGeometry {
6873 #** @method list GetPoint($index = 0)
6876 # @return (x,y) or a list with more coordinates
6881 my $t = $self->GetGeometryType;
6882 my $has_z = HasZ($t);
6883 my $has_m = HasM($t);
6885 if (!$has_z && !$has_m) {
6886 $point = $self->GetPoint_2D($i);
6887 } elsif ($has_z && !$has_m) {
6888 $point = $self->GetPoint_3D($i);
6889 } elsif (!$has_z && $has_m) {
6890 $point = $self->GetPointZM($i);
6891 @$point = ($point->[0], $point->[1], $point->[3]);
6893 $point = $self->GetPointZM($i);
6895 return wantarray ? @$point : $point;
6898 #** @method scalar GetPointCount()
6900 # @return an integer
6905 #** @method GetPointZM()
6910 #** @method scalar GetPoint_2D($index = 0)
6913 # @return (x,y) or a list with more coordinates
6918 #** @method scalar GetPoint_3D($index = 0)
6921 # @return (x,y) or a list with more coordinates
6926 #** @method Geo::OSR::SpatialReference GetSpatialReference()
6928 # @return a new Geo::OSR::SpatialReference object
6930 sub GetSpatialReference {
6933 #** @method scalar GetX($index = 0)
6941 #** @method scalar GetY($index = 0)
6949 #** @method scalar GetZ($index = 0)
6957 #** @method HasCurveGeometry()
6959 sub HasCurveGeometry {
6962 #** @method Geo::OGR::Geometry Intersection($other)
6964 # @param other a Geo::OGR::Geometry object
6965 # @return a new Geo::OGR::Geometry object
6970 #** @method scalar Intersects($other)
6972 # @note a.k.a. Intersect (deprecated)
6973 # @param other a Geo::OGR::Geometry object
6974 # @return true if this geometry intersects with the other geometry, false otherwise
6984 #** @method scalar IsEmpty()
6986 # Test whether the geometry is empty (has no points, or, for a point,
6987 # has coordinate dimension of zero).
6993 #** @method IsMeasured()
6998 #** @method scalar IsRing()
7000 # Test if the geometry is a ring. Requires GEOS in GDAL.
7006 #** @method scalar IsSimple()
7008 # Test the simplicity of the geometry (OGC sense). Requires GEOS in GDAL.
7014 #** @method scalar IsValid()
7016 # Test the validity of the geometry (OGC sense). Requires GEOS in GDAL.
7022 #** @method scalar Length()
7024 # @return the length of the linestring
7029 #** @method MakeValid()
7034 #** @method Move($dx, $dy, $dz)
7036 # Move every point of the object as defined by the parameters.
7039 # @param dz [optional]
7044 #** @method Normalize()
7049 #** @method scalar Overlaps($other)
7051 # @param other a Geo::OGR::Geometry object
7052 # @return true if this geometry overlaps the other geometry, false otherwise
7057 #** @method list Point($index, $x, $y, $z)
7059 # Get or set the point
7060 # @param index The index of the point. Optional (ignored if given) for
7061 # Point and Point25D geometries.
7062 # @param x [optional]
7063 # @param y [optional]
7064 # @param z [optional]
7071 my $t = $self->GetGeometryType;
7073 if (Flatten($t) == $Geo::OGR::wkbPoint) {
7074 my $has_z = HasZ($t);
7075 my $has_m = HasM($t);
7076 if (!$has_z && !$has_m) {
7079 } elsif ($has_z || $has_m) {
7087 $i = shift unless defined $i;
7088 $self->SetPoint($i, @_);
7090 return unless defined wantarray;
7091 my $point = $self->GetPoint;
7092 return wantarray ? @$point : $point;
7095 #** @method PointOnSurface()
7097 sub PointOnSurface {
7100 #** @method array reference Points(arrayref points)
7102 # Get or set the points of the geometry. The points (vertices) are
7103 # stored in obvious lists of lists. When setting, the geometry is
7104 # first emptied. The method uses internally either AddPoint_2D or
7105 # AddPoint_3D depending on the coordinate dimension of the input data.
7107 # @note The same structure may represent different geometries
7108 # depending on the actual geometry type of the object.
7110 # @param points [optional] A reference to an array. A point is a reference to an
7111 # array of numbers, a linestring or a ring is a reference to an array of points,
7112 # a polygon is a reference to an array of rings, etc.
7114 # @return A reference to an array.
7118 my $t = $self->GetGeometryType;
7119 my $has_z = HasZ($t);
7120 my $has_m = HasM($t);
7122 $postfix .=
'Z' if HasZ($t);
7123 $postfix .=
'M' if HasM($t);
7124 $t = i2s(geometry_type => Flatten($t));
7128 if ($t eq
'Unknown' or $t eq
'None' or $t eq
'GeometryCollection') {
7129 error(
"Can't set points of a geometry of type '$t'.");
7130 } elsif ($t eq
'Point') {
7131 # support both "Point" as a list of one point and one point
7132 if (ref($points->[0])) {
7133 $self->AddPoint(@{$points->[0]});
7135 $self->AddPoint(@$points);
7137 } elsif ($t eq
'LineString' or $t eq
'LinearRing' or $t eq
'CircularString') {
7138 for my $p (@$points) {
7139 $self->AddPoint(@$p);
7141 } elsif ($t eq
'Polygon') {
7142 for my $r (@$points) {
7144 $ring->
Set3D(1)
if $has_z;
7145 $ring->SetMeasured(1)
if $has_m;
7147 $self->AddGeometryDirectly($ring);
7149 } elsif ($t eq
'MultiPoint') {
7150 for my $p (@$points) {
7153 $self->AddGeometryDirectly($point);
7155 } elsif ($t eq
'MultiLineString') {
7156 for my $l (@$points) {
7159 $self->AddGeometryDirectly($linestring);
7161 } elsif ($t eq
'MultiPolygon') {
7162 for my $p (@$points) {
7165 $self->AddGeometryDirectly($polygon);
7169 return unless defined wantarray;
7170 $self->_GetPoints();
7173 #** @method Polygonize()
7178 #** @method RemoveGeometry()
7180 sub RemoveGeometry {
7183 #** @method RemoveLowerDimensionSubGeoms()
7185 sub RemoveLowerDimensionSubGeoms {
7188 #** @method Segmentize($MaxLength)
7190 # Modify the geometry such it has no segment longer than the given length.
7191 # @param MaxLength the given length
7201 #** @method SetCoordinateDimension($dimension)
7205 sub SetCoordinateDimension {
7208 #** @method SetMeasured()
7213 #** @method SetPoint($index, $x, $y, $z)
7215 # Set the data of a point or a line string. Note that the coordinate
7216 # dimension is automatically upgraded to 25D (3) if z is given.
7220 # @param z [optional]
7224 my $t = $self->GetGeometryType;
7225 my $has_z = HasZ($t);
7226 my $has_m = HasM($t);
7227 if (!$has_z && !$has_m) {
7228 $self->SetPoint_2D(@_[0..2]);
7229 } elsif ($has_z && !$has_m) {
7230 $self->SetPoint_3D(@_[0..3]);
7231 } elsif (!$has_z && $has_m) {
7232 $self->SetPointM(@_[0..3]);
7234 $self->SetPointZM(@_[0..4]);
7238 #** @method SetPointM()
7243 #** @method SetPointZM()
7248 #** @method SetPoint_2D($index, $x, $y)
7257 #** @method SetPoint_3D($index, $x, $y, $z)
7259 # Set the data of a point or a line string. Note that the coordinate
7260 # dimension is automatically upgraded to 25D (3).
7269 #** @method Geo::OGR::Geometry Simplify($Tolerance)
7271 # Simplify the geometry.
7272 # @param Tolerance the length tolerance for the simplification
7274 # @return a new Geo::OSR::Geometry object
7279 #** @method SimplifyPreserveTopology()
7281 sub SimplifyPreserveTopology {
7284 #** @method SwapXY()
7289 #** @method Geo::OGR::Geometry SymDifference($other)
7291 # Compute symmetric difference.
7292 # @note a.k.a. SymmetricDifference
7293 # @param other a Geo::OGR::Geometry object
7294 # @return a new Geo::OGR::Geometry object
7300 #** @method scalar Touches($other)
7302 # @param other a Geo::OGR::Geometry object
7303 # @return true if this geometry touches the other geometry, false otherwise
7308 #** @method Transform($trans)
7310 # @param trans a Geo::OSR::CoordinateTransformation object
7315 #** @method TransformTo($srs)
7317 # @param srs a Geo::OSR::SpatialReference object
7322 #** @method Geo::OGR::Geometry Union($other)
7324 # @param other a Geo::OGR::Geometry object
7325 # @return a new Geo::OGR::Geometry object
7330 #** @method Geo::OGR::Geometry UnionCascaded()
7332 # @return a new Geo::OGR::Geometry object
7343 #** @method scalar Within($other)
7345 # @param other a Geo::OGR::Geometry object
7346 # @return true if this geometry is within the other geometry, false otherwise
7351 #** @method scalar WkbSize()
7353 # @return an integer
7358 #** @method Geo::OGR::Geometry new(%params)
7360 # @param %params A named parameter, one of:
7361 # - \a GeometryType one the supported geometry types, see Geo::OGR::GeometryTypes.
7362 # - \a WKT a well known text string, which defines a geometry.
7363 # - \a WKB a well known binary string, which defines a geometry.
7364 # - \a HEXWKB WKB in hexadecimal.
7365 # - \a HEXEWKB PostGIS extended WKB.
7366 # - \a GML geometry written in Geographic Markup Language.
7367 # - \a GeoJSON geometry written in GeoJSON (JavaScript Object Notation for Geographic data).
7368 # - \a arc a reference to a list of values defining an arc: [CenterX,
7369 # CenterY, CenterZ, PrimaryRadius, SecondaryRadius, Rotation,
7370 # StartAngle, EndAngle, MaxAngleStepSizeDegrees] (see also Geo::OGR::Geometry::ApproximateArcAngles)
7371 # - \a Points An anonymous array as in method
7372 # Geo::OGR::Geometry::Points; Note: requires also GeometryType
7375 # @return a new Geo::OGR::Geometry object.
7380 if (@_ == 1 and ref($_[0]) eq
'HASH') {
7382 } elsif (@_ % 2 == 0) {
7385 ($param{GeometryType}) = @_;
7387 my $type = $param{GeometryType}
7388 my $srs = $param{SRS}
7389 my $wkt = $param{WKT}
7390 my $wkb = $param{WKB}
7391 my $hex = $param{HEXEWKB}
7394 # EWKB contains SRID
7395 $srid = substr($hex, 10, 8);
7396 substr($hex, 10, 8) =
'';
7398 $hex = $param{HEXWKB}
7402 for (my $i = 0; $i < length($hex); $i+=2) {
7403 $wkb .= chr(hex(substr($hex,$i,2)));
7406 my $gml = $param{GML}
7407 my $json = $param{GeoJSON}
7408 my $points = $param{Points}
7409 my $arc = $param{Arc}
7412 $self = Geo::OGRc::CreateGeometryFromWkt($wkt, $srs);
7413 } elsif (defined $wkb) {
7414 $self = Geo::OGRc::CreateGeometryFromWkb($wkb, $srs);
7415 } elsif (defined $gml) {
7416 $self = Geo::OGRc::CreateGeometryFromGML($gml);
7417 } elsif (defined $json) {
7418 $self = Geo::OGRc::CreateGeometryFromJson($json);
7419 } elsif (defined $type) {
7420 $type = s2i(geometry_type => $type);
7421 $self = Geo::OGRc::new_Geometry($type); # flattens the type
7422 $self->Set3D(1)
if HasZ($type);
7423 $self->SetMeasured(1)
if HasM($type);
7424 } elsif (defined $arc) {
7425 $self = Geo::OGRc::ApproximateArcAngles(@$arc);
7427 error(1, undef, map {$_=>1} qw/GeometryType WKT WKB HEXEWKB HEXWKB GML GeoJSON Arc/);
7429 bless $self, $pkg
if defined $self;
7430 $self->Points($points)
if $points;
7434 #** @class Geo::OGR::Layer
7435 # @brief A collection of similar features.
7436 # @details A layer object is typically obtained with a data source object. A
7437 # layer has a data model (a schema), which is maintained in a
7438 # definition object, and a set of features, which contain data
7439 # according to the data model. The schema is typically set when the
7440 # layer is created or opened, but it may be altered somewhat with
7441 # methods Geo::OGR::Layer::CreateField,
7442 # Geo::OGR::Layer::AlterFieldDefn, and
7443 # Geo::OGR::Layer::DeleteField. Features and/or their data can be
7444 # read, inserted and deleted. Reading can be filtered. Layers can be
7445 # compared to each other with methods Clip, Erase, Identity,
7446 # Intersection, SymDifference, Union, and Update.
7447 # A layer may have metadata OLMD_FID64 => 'YES' if it holds features
7448 # with 64 bit FIDs. The metadata of a layer can be obtained with
7449 # GetMetadata method.
7451 package Geo::OGR::Layer;
7455 #** @method AlterFieldDefn($name, %params)
7457 # @param field the name of the field to be altered.
7458 # @param params as in Geo::OGR::FieldDefn::new. Width and
7459 # Precision should be both or neither.
7460 # @note Only non-spatial fields can be altered.
7461 # @note Also the deprecated form AlterFieldDefn($field,
7462 # Geo::OGR::FieldDefn $Defn, $Flags) works.
7464 sub AlterFieldDefn {
7466 my $index = $self->GetLayerDefn->GetFieldIndex(shift
7467 my $param = @_ % 2 == 0 ? {@_} : shift;
7468 if (blessed($param) and $param->isa(
'Geo::OGR::FieldDefn')) {
7469 _AlterFieldDefn($self, $index, @_);
7471 my $definition = Geo::OGR::FieldDefn->new($param);
7473 $flags |= 1 if exists $param->{Name};
7474 $flags |= 2
if exists $param->{Type};
7475 $flags |= 4
if exists $param->{Width} or exists $param->{Precision};
7476 $flags |= 8
if exists $param->{Nullable};
7477 $flags |= 16
if exists $param->{Default};
7478 _AlterFieldDefn($self, $index, $definition, $flags);
7482 #** @method list Capabilities()
7484 # Both a package subroutine and an object method.
7485 # @return a list of capabilities. The object method returns a list of
7486 # the capabilities the layer has. The package subroutine returns a list of
7487 # all potential capabilities a layer may have. These are currently:
7488 # AlterFieldDefn, CreateField, CreateGeomField, CurveGeometries, DeleteFeature, DeleteField, FastFeatureCount, FastGetExtent, FastSetNextByIndex, FastSpatialFilter, IgnoreFields, MeasuredGeometries, RandomRead, RandomWrite, ReorderFields, SequentialWrite, StringsAsUTF8, and Transactions.
7492 # @cap = Geo::OGR::Layer::Capabilities(); # the package subroutine
7493 # @cap = $layer->Capabilities(); # the object method
7497 return @CAPABILITIES
if @_ == 0;
7500 for my $cap (@CAPABILITIES) {
7501 push @cap, $cap
if _TestCapability($self, $CAPABILITIES{$cap});
7506 #** @method Clip(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
7508 # Clip off areas that are not covered by the method layer. The schema
7509 # of the result layer can be set before calling this method, or is
7510 # initialized to to contain all fields from
7511 # this and method layer.
7512 # @param method method layer.
7513 # @param result result layer.
7514 # @param options a reference to an options hash.
7515 # @param callback [optional] a reference to a subroutine, which will
7516 # be called with parameters (number progress, string msg, callback_data)
7517 # @param callback_data [optional]
7522 #** @method CommitTransaction()
7525 sub CommitTransaction {
7528 #** @method CreateFeature()
7533 #** @method CreateField(%params)
7536 # @param params as in Geo::OGR::FieldDefn::new or
7537 # Geo::OGR::GeomFieldDefn::new, plus ApproxOK (whose default is true).
7541 my %defaults = ( ApproxOK => 1,
7545 } elsif (ref($_[0]) eq
'HASH') {
7547 } elsif (@_ % 2 == 0) {
7550 ($params{Defn}) = @_;
7552 for my $k (keys %defaults) {
7555 if (blessed($params{Defn}) and $params{Defn}->isa(
'Geo::OGR::FieldDefn')) {
7556 $self->_CreateField($params{Defn}, $params{ApproxOK});
7557 } elsif (blessed($_[0]) and $params{Defn}->isa(
'Geo::OGR::GeomFieldDefn')) {
7558 $self->CreateGeomField($params{Defn}, $params{ApproxOK});
7560 # if Name and Type are missing, assume Name => Type
7561 if (!(exists $params{Name} && exists $params{Type})) {
7562 for my $key (sort keys %params) {
7563 if (s_exists(field_type => $params{$key}) ||
7564 s_exists(geometry_type => $params{$key}))
7566 $params{Name} = $key;
7567 $params{Type} = $params{$key};
7568 delete $params{$key};
7573 my $a = $params{ApproxOK};
7574 delete $params{ApproxOK};
7575 if (exists $params{GeometryType}) {
7576 $params{Type} = $params{GeometryType};
7577 delete $params{GeometryType};
7579 if (s_exists(field_type => $params{Type})) {
7581 _CreateField($self, $fd, $a);
7582 } elsif (s_exists(geometry_type => $params{Type})) {
7584 CreateGeomField($self, $fd, $a);
7585 } elsif ($params{Type} ) {
7586 error(
"Invalid field type: $params{Type}.")
7587 } elsif ($params{Name} ) {
7588 error(
"Missing type for field: $params{Name}.")
7590 error(
"Missing name and type for a field.")
7595 #** @method DataSource()
7600 #** @method Dataset()
7607 #** @method DeleteFeature($fid)
7609 # @param fid feature id
7614 #** @method DeleteField($field)
7616 # Delete an existing field from a layer.
7617 # @param field name (or index) of the field which is deleted
7618 # @note Only non-spatial fields can be deleted.
7621 my ($self, $field) = @_;
7622 my $index = $self->GetLayerDefn->GetFieldIndex($field
7623 _DeleteField($self, $index);
7626 #** @method Erase(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
7628 # The result layer contains features whose geometries represent areas
7629 # that are in the input layer but not in the method layer. The
7630 # features in the result layer have attributes from the input
7631 # layer. The schema of the result layer can be set by the user or, if
7632 # it is empty, is initialized to contain all fields in the input
7634 # @param method method layer.
7635 # @param result result layer.
7636 # @param options a reference to an options hash.
7637 # @param callback [optional] a reference to a subroutine, which will
7638 # be called with parameters (number progress, string msg, callback_data)
7639 # @param callback_data [optional]
7644 #** @method Geo::OGR::Feature Feature($f)
7647 # @param f [optional] feature id, a feature, a row, or a tuple
7649 # @note If the argument feature has a null FID (FID not set) the
7650 # feature is inserted into the layer as a new feature. If the FID is
7651 # non null, then the feature replaces the feature in the layer with
7654 # @return a new Geo::OGR::Feature object that represents the feature
7660 return $self->GetFeature($x) unless $x && ref $x;
7661 # Insert or Set depending on the FID
7663 if (ref $x eq
'ARRAY') {
7664 # FID is the first item in the array
7666 } elsif (ref $x eq
'HASH') {
7673 if (!defined $fid || $fid < 0) {
7674 $self->InsertFeature($x);
7676 $self->SetFeature($x);
7680 #** @method scalar FeatureCount($force = 1)
7682 # A.k.a GetFeatureCount
7689 #** @method Features()
7693 $self->ResetReading;
7695 return $self->GetNextFeature;
7699 #** @method ForFeatures($code, $in_place)
7701 # @note experimental, the syntax may change
7703 # Call code for all features. This is a simple wrapper for
7704 # ResetReading and while(GetNextFeature).
7708 # $layer->ForFeatures(sub {my $f = shift; $self->DeleteFeature($f->FID)}); # empties the layer
7711 # @param code a reference to a subroutine, which is called with each
7712 # feature as an argument
7713 # @param in_place if set to true, the feature is stored back to the
7719 my $in_place = shift;
7720 $self->ResetReading;
7721 while (my $f = $self->GetNextFeature) {
7724 $self->SetFeature($f)
if $in_place;
7728 #** @method ForGeometries($code, $in_place)
7730 # @note experimental, the syntax may change
7732 # Call code for all geometries. This is a simple wrapper for
7733 # ResetReading and while(GetNextFeature).
7738 # $layer->ForGeometries(sub {my $g = shift; $area += $g->Area}); # computes the total area
7741 # @param code a reference to a subroutine, which is called with each
7742 # geometry as an argument
7743 # @param in_place if set to true, the geometry is stored back to the
7749 my $in_place = shift;
7750 $self->ResetReading;
7751 while (my $f = $self->GetNextFeature) {
7752 my $g = $f->Geometry();
7756 $self->SetFeature($f);
7761 #** @method Geometries()
7765 $self->ResetReading;
7767 my $f = $self->GetNextFeature;
7769 return $f->Geometry;
7773 #** @method scalar GeometryType($field)
7775 # @param field the name or index of the spatial field.
7776 # @return the geometry type of the spatial field.
7780 my $d = $self->GetDefn;
7781 my $field = $d->GetGeomFieldIndex(shift
7782 my $fd = $d->_GetGeomFieldDefn($field);
7783 return $fd->Type
if $fd;
7786 #** @method Geo::OGR::DataSource GetDataSource()
7788 # @return the data source object to which this layer object belongs to.
7795 #** @method Geo::OGR::FeatureDefn GetDefn()
7797 # A.k.a GetLayerDefn.
7798 # @return a Geo::OGR::FeatureDefn object.
7802 my $defn = $self->GetLayerDefn;
7806 #** @method list GetExtent($force = 1)
7808 # @param force compute the extent even if it is expensive
7809 # @note In scalar context returns a reference to an anonymous array
7810 # containing the extent.
7811 # @return the extent ($minx, $maxx, $miny, $maxy)
7813 # @return the extent = ($minx, $maxx, $miny, $maxy) as a listref
7818 #** @method scalar GetFIDColumn()
7820 # @return the name of the underlying database column being used as the
7821 # FID column, or "" if not supported.
7826 #** @method Geo::OGR::Feature GetFeature($fid)
7828 # @param fid feature id
7829 # @return a new Geo::OGR::Feature object that represents the feature in the layer.
7832 my ($self, $fid) = @_;
7834 my $f = $self->_GetFeature($fid);
7835 error(2,
"FID=$fid",
'"Feature') unless ref $f eq 'Geo::
OGR::Feature';
7839 #** @method GetFeatureCount()
7841 sub GetFeatureCount {
7844 #** @method scalar GetFeaturesRead()
7848 sub GetFeaturesRead {
7851 #** @method scalar GetFieldDefn($name)
7853 # Get the definition of a field.
7854 # @param name the name of the field.
7855 # @return a Geo::OGR::FieldDefn object.
7859 my $d = $self->GetDefn;
7860 my $field = $d->GetFieldIndex(shift
7861 return $d->_GetFieldDefn($field);
7864 #** @method list GetFieldNames()
7866 # @return a list of the names of the fields in this layer. The
7867 # non-geometry field names are first in the list and then the geometry
7872 my $d = $self->GetDefn;
7874 for (my $i = 0; $i < $d->GetFieldCount; $i++) {
7875 push @ret, $d->GetFieldDefn($i)->Name();
7877 for (my $i = 0; $i < $d->GetGeomFieldCount; $i++) {
7878 push @ret, $d->GetGeomFieldDefn($i)->Name();
7883 #** @method scalar GetGeomFieldDefn($name)
7885 # Get the definition of a spatial field.
7886 # @param name the name of the spatial field.
7887 # @return a Geo::OGR::GeomFieldDefn object.
7889 sub GetGeomFieldDefn {
7891 my $d = $self->GetDefn;
7892 my $field = $d->GetGeomFieldIndex(shift
7893 return $d->_GetGeomFieldDefn($field);
7896 #** @method scalar GetName()
7898 # @return the name of the layer.
7903 #** @method Geo::OGR::Feature GetNextFeature()
7905 # @return iteratively Geo::OGR::Feature objects from the layer. The
7906 # iteration obeys the spatial and the attribute filter.
7908 sub GetNextFeature {
7911 #** @method hash reference GetSchema()
7913 # @brief Get the schema of this layer.
7914 # @note The schema of a layer cannot be set with this method. If you
7915 # have a Geo::OGR::FeatureDefn object before creating the layer, use
7916 # its schema in the Geo::OGR::CreateLayer method.
7917 # @return the schema of this layer, as in Geo::OGR::FeatureDefn::Schema.
7921 carp
"Schema of a layer should not be set directly." if @_;
7922 if (@_ and @_ % 2 == 0) {
7924 if ($schema{Fields}) {
7925 for my $field (@{$schema{Fields}}) {
7926 $self->CreateField($field);
7930 return $self->GetDefn->Schema;
7933 #** @method Geo::OGR::Geometry GetSpatialFilter()
7935 # @return a new Geo::OGR::Geometry object
7937 sub GetSpatialFilter {
7940 #** @method GetStyleTable()
7945 #** @method Identity(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
7947 # The result layer contains features whose geometries represent areas
7948 # that are in the input layer. The features in the result layer have
7949 # attributes from both input and method layers. The schema of the
7950 # result layer can be set by the user or, if it is empty, is
7951 # initialized to contain all fields in input and method layers.
7952 # @param method method layer.
7953 # @param result result layer.
7954 # @param options a reference to an options hash.
7955 # @param callback [optional] a reference to a subroutine, which will
7956 # be called with parameters (number progress, string msg, callback_data)
7957 # @param callback_data [optional]
7962 #** @method InsertFeature($feature)
7964 # Creates a new feature which has the schema of the layer and
7965 # initializes it with data from the argument. Then inserts the feature
7966 # into the layer (using CreateFeature). Uses Geo::OGR::Feature::Row or
7967 # Geo::OGR::Feature::Tuple.
7968 # @param feature a Geo::OGR::Feature object or reference to feature
7969 # data in a hash (as in Geo::OGR::Feature::Row) or in an array (as in
7970 # Geo::OGR::Feature::Tuple)
7971 # @return the new feature.
7975 my $feature = shift;
7976 error(
"Usage: \$feature->InsertFeature(reference to a hash or array).") unless ref($feature);
7978 $self->CreateFeature($new);
7979 return unless defined wantarray;
7983 #** @method Intersection(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
7985 # The result layer contains features whose geometries represent areas
7986 # that are common between features in the input layer and in the
7987 # method layer. The schema of the result layer can be set before
7988 # calling this method, or is initialized to contain all fields from
7989 # this and method layer.
7990 # @param method method layer.
7991 # @param result result layer.
7992 # @param options a reference to an options hash.
7993 # @param callback [optional] a reference to a subroutine, which will
7994 # be called with parameters (number progress, string msg, callback_data)
7995 # @param callback_data [optional]
8000 #** @method ReorderField()
8005 #** @method ReorderFields()
8010 #** @method ResetReading()
8012 # Initialize the layer object for iterative reading.
8017 #** @method RollbackTransaction()
8020 sub RollbackTransaction {
8023 #** @method hash reference Row(%row)
8025 # Get and/or set the data of a feature that has the supplied feature
8026 # id (the next feature obtained with GetNextFeature is used if feature
8027 # id is not given). Calls Geo::OGR::Feature::Row.
8028 # @param row [optional] feature data
8029 # @return a reference to feature data in a hash
8033 my $update = @_ > 0;
8035 my $feature = defined $row{FID} ? $self->GetFeature($row{FID}) : $self->GetNextFeature;
8036 return unless $feature;
8038 if (defined wantarray) {
8039 $ret = $feature->Row(@_);
8043 $self->SetFeature($feature)
if $update;
8044 return unless defined wantarray;
8048 #** @method SetAttributeFilter($filter_string)
8050 # Set or clear the attribute filter.
8051 # @param filter_string a SQL WHERE clause or undef to clear the
8054 sub SetAttributeFilter {
8057 #** @method SetFeature($feature)
8059 # @note The feature should have the same schema as the layer.
8061 # Replaces a feature in the layer based on the given feature's
8062 # id. Requires RandomWrite capability.
8063 # @param feature a Geo::OGR::Feature object
8068 #** @method SetIgnoredFields(@fields)
8070 # @param fields a list of field names
8072 sub SetIgnoredFields {
8075 #** @method SetNextByIndex($new_index)
8077 # @param new_index the index to which set the read cursor in the
8080 sub SetNextByIndex {
8083 #** @method SetSpatialFilter($filter)
8085 # @param filter [optional] a Geo::OGR::Geometry object. If not given,
8086 # removes the filter if there is one.
8088 sub SetSpatialFilter {
8091 #** @method SetSpatialFilterRect($minx, $miny, $maxx, $maxy)
8098 sub SetSpatialFilterRect {
8101 #** @method SetStyleTable()
8106 #** @method Geo::OGR::Geometry SpatialFilter(@filter)
8108 # @param filter [optional] a Geo::OGR::Geometry object or a string. An
8109 # undefined value removes the filter if there is one.
8110 # @return a new Geo::OGR::Geometry object
8111 # @param filter [optional] a rectangle ($minx, $miny, $maxx, $maxy).
8112 # @return a new Geo::OGR::Geometry object
8116 $self->SetSpatialFilter($_[0])
if @_ == 1;
8117 $self->SetSpatialFilterRect(@_)
if @_ == 4;
8118 return unless defined wantarray;
8119 $self->GetSpatialFilter;
8122 #** @method Geo::OSR::SpatialReference SpatialReference($name, Geo::OSR::SpatialReference sr)
8124 # @note A.k.a GetSpatialRef.
8125 # Get or set the projection of a spatial field of this layer. Gets or
8126 # sets the projection of the first field if no field name is given.
8127 # @param name [optional] a name of a spatial field in this layer.
8128 # @param sr [optional] a Geo::OSR::SpatialReference object,
8129 # which replaces the existing projection.
8130 # @return a Geo::OSR::SpatialReference object, which represents the
8131 # projection in the given spatial field.
8133 sub SpatialReference {
8135 my $d = $self->GetDefn;
8136 my $field = @_ == 2 ? $d->GetGeomFieldIndex(shift
8138 my $d2 = $d->_GetGeomFieldDefn($field);
8139 $d2->SpatialReference($sr)
if defined $sr;
8140 return $d2->SpatialReference()
if defined wantarray;
8143 #** @method StartTransaction()
8146 sub StartTransaction {
8149 #** @method SymDifference(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
8151 # The result layer contains features whose geometries represent areas
8152 # that are in either in the input layer or in the method layer but not
8153 # in both. The features in the result layer have attributes from both
8154 # input and method layers. For features which represent areas that are
8155 # only in the input or in the method layer the respective attributes
8156 # have undefined values. The schema of the result layer can be set by
8157 # the user or, if it is empty, is initialized to contain all fields in
8158 # the input and method layers.
8159 # @param method method layer.
8160 # @param result result layer.
8161 # @param options a reference to an options hash.
8162 # @param callback [optional] a reference to a subroutine, which will
8163 # be called with parameters (number progress, string msg, callback_data)
8164 # @param callback_data [optional]
8169 #** @method SyncToDisk()
8175 #** @method scalar TestCapability($cap)
8177 # @param cap A capability string.
8178 # @return a boolean value indicating whether the layer has the
8179 # specified capability.
8181 sub TestCapability {
8182 my($self, $cap) = @_;
8183 return _TestCapability($self, $CAPABILITIES{$cap});
8186 #** @method list Tuple(@tuple)
8188 # Get and/set the data of a feature that has the supplied feature id
8189 # (the next feature obtained with GetNextFeature is used if feature id
8190 # is not given). The expected data in the tuple is: ([feature id,]
8191 # non-spatial fields, spatial fields). Calls Geo::OGR::Feature::Tuple.
8192 # @param tuple [optional] feature data
8193 # @note The schema of the tuple needs to be the same as that of the
8195 # @return a reference to feature data in an array
8200 my $feature = defined $FID ? $self->GetFeature($FID) : $self->GetNextFeature;
8201 return unless $feature;
8203 unshift @_, $feature->GetFID
if $set;
8205 if (defined wantarray) {
8206 @ret = $feature->Tuple(@_);
8208 $feature->Tuple(@_);
8210 $self->SetFeature($feature)
if $set;
8211 return unless defined wantarray;
8215 #** @method Union(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
8217 # The result layer contains features whose geometries represent areas
8218 # that are in either in the input layer or in the method layer. The
8219 # schema of the result layer can be set before calling this method, or
8220 # is initialized to contain all fields from this and method layer.
8221 # @param method method layer.
8222 # @param result result layer.
8223 # @param options a reference to an options hash.
8224 # @param callback [optional] a reference to a subroutine, which will
8225 # be called with parameters (number progress, string msg, callback_data)
8226 # @param callback_data [optional]
8231 #** @method Update(Geo::OGR::Layer method, Geo::OGR::Layer result, hashref options, coderef callback, $callback_data)
8233 # The result layer contains features whose geometries represent areas
8234 # that are either in the input layer or in the method layer. The
8235 # features in the result layer have areas of the features of the
8236 # method layer or those ares of the features of the input layer that
8237 # are not covered by the method layer. The features of the result
8238 # layer get their attributes from the input layer. The schema of the
8239 # result layer can be set by the user or, if it is empty, is
8240 # initialized to contain all fields in the input layer.
8241 # @param method method layer.
8242 # @param result result layer.
8243 # @param options a reference to an options hash.
8244 # @param callback [optional] a reference to a subroutine, which will
8245 # be called with parameters (number progress, string msg, callback_data)
8246 # @param callback_data [optional]
8251 #** @class Geo::OGR::PreparedGeometry
8253 package Geo::OGR::PreparedGeometry;
8257 #** @method Contains()
8262 #** @method Intersects()
8267 #** @class Geo::OGR::StyleTable
8269 package Geo::OGR::StyleTable;
8273 #** @method AddStyle()
8283 #** @method GetLastStyleName()
8285 sub GetLastStyleName {
8288 #** @method GetNextStyle()
8293 #** @method LoadStyleTable()
8295 sub LoadStyleTable {
8298 #** @method ResetStyleStringReading()
8300 sub ResetStyleStringReading {
8303 #** @method SaveStyleTable()
8305 sub SaveStyleTable {
8312 my $self = Geo::OGRc::new_StyleTable(@_);
8313 bless $self, $pkg
if defined($self);
8317 # @brief Base class for projection related classes.
8322 #** @method list AngularUnits()
8323 # Package subroutine.
8324 # @return list of known angular units.
8327 return keys %ANGULAR_UNITS;
8330 #** @method CreateCoordinateTransformation()
8332 sub CreateCoordinateTransformation {
8335 #** @method list Datums()
8336 # Package subroutine.
8337 # @return list of known datums.
8340 return keys %DATUMS;
8343 #** @method GetPROJAuxDbPaths()
8345 sub GetPROJAuxDbPaths {
8348 #** @method GetPROJEnableNetwork()
8350 sub GetPROJEnableNetwork {
8353 #** @method GetPROJSearchPaths()
8355 sub GetPROJSearchPaths {
8358 #** @method GetPROJVersionMajor()
8360 sub GetPROJVersionMajor {
8363 #** @method GetPROJVersionMicro()
8365 sub GetPROJVersionMicro {
8368 #** @method GetPROJVersionMinor()
8370 sub GetPROJVersionMinor {
8373 #** @method scalar GetUserInputAsWKT($name)
8374 # Package subroutine.
8375 # @param name the user input
8376 # @return a WKT string.
8378 sub GetUserInputAsWKT {
8381 #** @method scalar GetWellKnownGeogCSAsWKT($name)
8382 # Package subroutine.
8383 # @brief Get well known geographic coordinate system as WKT
8384 # @param name a well known name
8385 # @return a WKT string.
8387 sub GetWellKnownGeogCSAsWKT {
8390 #** @method list LinearUnits()
8391 # Package subroutine.
8392 # @return list of known linear units.
8395 return keys %LINEAR_UNITS;
8398 #** @method OAMS_AUTHORITY_COMPLIANT()
8400 sub OAMS_AUTHORITY_COMPLIANT {
8403 #** @method OAMS_CUSTOM()
8408 #** @method OAMS_TRADITIONAL_GIS_ORDER()
8410 sub OAMS_TRADITIONAL_GIS_ORDER {
8413 #** @method OAO_Down()
8418 #** @method OAO_East()
8423 #** @method OAO_North()
8428 #** @method OAO_Other()
8433 #** @method OAO_South()
8438 #** @method OAO_Up()
8443 #** @method OAO_West()
8448 #** @method OSRAreaOfUse_east_lon_degree_get()
8450 sub OSRAreaOfUse_east_lon_degree_get {
8453 #** @method OSRAreaOfUse_name_get()
8455 sub OSRAreaOfUse_name_get {
8458 #** @method OSRAreaOfUse_north_lat_degree_get()
8460 sub OSRAreaOfUse_north_lat_degree_get {
8463 #** @method OSRAreaOfUse_south_lat_degree_get()
8465 sub OSRAreaOfUse_south_lat_degree_get {
8468 #** @method OSRAreaOfUse_west_lon_degree_get()
8470 sub OSRAreaOfUse_west_lon_degree_get {
8473 #** @method PROJ_ERR_COORD_TRANSFM()
8475 sub PROJ_ERR_COORD_TRANSFM {
8478 #** @method PROJ_ERR_COORD_TRANSFM_GRID_AT_NODATA()
8480 sub PROJ_ERR_COORD_TRANSFM_GRID_AT_NODATA {
8483 #** @method PROJ_ERR_COORD_TRANSFM_INVALID_COORD()
8485 sub PROJ_ERR_COORD_TRANSFM_INVALID_COORD {
8488 #** @method PROJ_ERR_COORD_TRANSFM_NO_OPERATION()
8490 sub PROJ_ERR_COORD_TRANSFM_NO_OPERATION {
8493 #** @method PROJ_ERR_COORD_TRANSFM_OUTSIDE_GRID()
8495 sub PROJ_ERR_COORD_TRANSFM_OUTSIDE_GRID {
8498 #** @method PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN()
8500 sub PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN {
8503 #** @method PROJ_ERR_INVALID_OP()
8505 sub PROJ_ERR_INVALID_OP {
8508 #** @method PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID()
8510 sub PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID {
8513 #** @method PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE()
8515 sub PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE {
8518 #** @method PROJ_ERR_INVALID_OP_MISSING_ARG()
8520 sub PROJ_ERR_INVALID_OP_MISSING_ARG {
8523 #** @method PROJ_ERR_INVALID_OP_MUTUALLY_EXCLUSIVE_ARGS()
8525 sub PROJ_ERR_INVALID_OP_MUTUALLY_EXCLUSIVE_ARGS {
8528 #** @method PROJ_ERR_INVALID_OP_WRONG_SYNTAX()
8530 sub PROJ_ERR_INVALID_OP_WRONG_SYNTAX {
8533 #** @method PROJ_ERR_OTHER()
8535 sub PROJ_ERR_OTHER {
8538 #** @method PROJ_ERR_OTHER_API_MISUSE()
8540 sub PROJ_ERR_OTHER_API_MISUSE {
8543 #** @method PROJ_ERR_OTHER_NETWORK_ERROR()
8545 sub PROJ_ERR_OTHER_NETWORK_ERROR {
8548 #** @method PROJ_ERR_OTHER_NO_INVERSE_OP()
8550 sub PROJ_ERR_OTHER_NO_INVERSE_OP {
8553 #** @method list Parameters()
8554 # Package subroutine.
8555 # @return list of known projection parameters.
8558 return keys %PARAMETERS;
8561 #** @method list Projections()
8562 # Package subroutine.
8563 # @return list of known projections.
8566 return keys %PROJECTIONS;
8569 #** @method SRS_PM_GREENWICH()
8571 sub SRS_PM_GREENWICH {
8574 #** @method SRS_WGS84_INVFLATTENING()
8576 sub SRS_WGS84_INVFLATTENING {
8579 #** @method SRS_WGS84_SEMIMAJOR()
8581 sub SRS_WGS84_SEMIMAJOR {
8584 #** @method SRS_WKT_WGS84_LAT_LONG()
8586 sub SRS_WKT_WGS84_LAT_LONG {
8589 #** @method SetPROJAuxDbPath()
8591 sub SetPROJAuxDbPath {
8594 #** @method SetPROJAuxDbPaths()
8596 sub SetPROJAuxDbPaths {
8599 #** @method SetPROJEnableNetwork()
8601 sub SetPROJEnableNetwork {
8604 #** @method SetPROJSearchPath()
8606 sub SetPROJSearchPath {
8609 #** @method SetPROJSearchPaths()
8611 sub SetPROJSearchPaths {
8614 #** @class Geo::OSR::AreaOfUse
8616 package Geo::OSR::AreaOfUse;
8624 my $self = Geo::OSRc::new_AreaOfUse(@_);
8625 bless $self, $pkg
if defined($self);
8628 #** @class Geo::OSR::CoordinateTransformation
8629 # @brief An object for transforming from one projection to another.
8632 package Geo::OSR::CoordinateTransformation;
8636 #** @method TransformBounds()
8638 sub TransformBounds {
8641 #** @method array reference TransformPoint($x, $y, $z)
8645 # @param z [optional]
8646 # @return arrayref = [$x, $y, $z]
8648 sub TransformPoint {
8651 #** @method TransformPointWithErrorCode()
8653 sub TransformPointWithErrorCode {
8656 #** @method TransformPoints(arrayref points)
8658 # @param points [in/out] a reference to a list of points (line string
8659 # or ring) that is modified in-place. A list of points is: ([x, y, z],
8660 # [x, y, z], ...), where z is optional. Supports also lists of line
8661 # strings and polygons.
8663 sub TransformPoints {
8664 my($self, $points) = @_;
8665 _TransformPoints($self, $points),
return unless ref($points->[0]->[0]);
8666 for my $p (@$points) {
8667 TransformPoints($self, $p);
8671 # This file was automatically generated by SWIG (http:
8674 # Do not make changes to this file unless you know what you are doing--modify
8675 # the SWIG interface file instead.
8678 #** @method Geo::OSR::CoordinateTransformation new($src, $dst)
8680 # @param src a Geo::OSR::SpatialReference object
8681 # @param dst a Geo::OSR::SpatialReference object
8682 # @return a new Geo::OSR::CoordinateTransformation object
8686 my $self = Geo::OSRc::new_CoordinateTransformation(@_);
8687 bless $self, $pkg
if defined($self);
8690 #** @class Geo::OSR::CoordinateTransformationOptions
8692 package Geo::OSR::CoordinateTransformationOptions;
8696 #** @method SetAreaOfInterest()
8698 sub SetAreaOfInterest {
8701 #** @method SetBallparkAllowed()
8703 sub SetBallparkAllowed {
8706 #** @method SetDesiredAccuracy()
8708 sub SetDesiredAccuracy {
8711 #** @method SetOperation()
8720 my $self = Geo::OSRc::new_CoordinateTransformationOptions(@_);
8721 bless $self, $pkg
if defined($self);
8724 #** @class Geo::OSR::SpatialReference
8725 # @brief A spatial reference system.
8726 # @details <a href="http://www.gdal.org/classOGRSpatialReference.html">Documentation
8727 # of the underlying C++ class at www.gdal.org</a>
8729 package Geo::OSR::SpatialReference;
8733 #** @method AddGuessedTOWGS84()
8735 sub AddGuessedTOWGS84 {
8743 #** @method AutoIdentifyEPSG()
8745 # Set EPSG authority info if possible.
8747 sub AutoIdentifyEPSG {
8750 #** @method Geo::OSR::SpatialReference Clone()
8752 # Make a duplicate of this SpatialReference object.
8753 # @return a new Geo::OSR::SpatialReference object
8758 #** @method Geo::OSR::SpatialReference CloneGeogCS()
8760 # Make a duplicate of the GEOGCS node of this SpatialReference object.
8761 # @return a new Geo::OSR::SpatialReference object
8766 #** @method ConvertToOtherProjection()
8768 sub ConvertToOtherProjection {
8771 #** @method CopyGeogCSFrom($rhs)
8773 # @param rhs Geo::OSR::SpatialReference
8775 sub CopyGeogCSFrom {
8778 #** @method DemoteTo2D()
8783 #** @method EPSGTreatsAsLatLong()
8785 # Returns TRUE if EPSG feels this geographic coordinate system should be treated as having lat/long coordinate ordering.
8787 sub EPSGTreatsAsLatLong {
8790 #** @method EPSGTreatsAsNorthingEasting()
8792 sub EPSGTreatsAsNorthingEasting {
8795 #** @method Export($format)
8797 # Export the spatial reference to a selected format.
8800 # @param format One of the following. The return value is explained
8801 # after the format. Other arguments are explained in parenthesis.
8802 # - WKT (Text): Well Known Text string
8803 # - PrettyWKT: Well Known Text string nicely formatted (simplify)
8804 # - Proj4: PROJ.4 string
8805 # - PCI: a list: ($proj_string, $units, [$parms1, ...])
8806 # - USGS: a list: ($code, $zone, [$parms1, ...], $datum)
8807 # - GML (XML): GML based string (dialect)
8808 # - MapInfoCS (MICoordSys): MapInfo style coordinate system definition
8810 # @note The named parameter syntax also works and is needed is those
8811 # cases when other arguments need or may be given. The format should
8812 # be given using key as, 'to' or 'format'.
8814 # @note ExportTo* and AsText methods also exist but are not documented here.
8816 # @return a scalar or a list depending on the export format
8821 $format = pop
if @_ == 1;
8824 my $simplify = $params{simplify}
8825 my $dialect = $params{dialect}
8827 WKT => sub {
return ExportToWkt($self) },
8828 Text => sub {
return ExportToWkt($self) },
8829 PrettyWKT => sub {
return ExportToPrettyWkt($self, $simplify) },
8830 Proj4 => sub {
return ExportToProj4($self) },
8831 PCI => sub {
return ExportToPCI($self) },
8832 USGS => sub {
return ExportToUSGS($self) },
8833 GML => sub {
return ExportToXML($self, $dialect) },
8834 XML => sub {
return ExportToXML($self, $dialect) },
8835 MICoordSys => sub {
return ExportToMICoordSys() },
8836 MapInfoCS => sub {
return ExportToMICoordSys() },
8838 error(1, $format, \%converters) unless $converters{$format};
8839 return $converters{$format}->();
8842 #** @method ExportToPROJJSON()
8844 sub ExportToPROJJSON {
8847 #** @method scalar GetAngularUnits()
8851 sub GetAngularUnits {
8854 #** @method GetAngularUnitsName()
8856 sub GetAngularUnitsName {
8859 #** @method GetAreaOfUse()
8864 #** @method scalar GetAttrValue($name, $child = 0)
8873 #** @method scalar GetAuthorityCode($target_key)
8878 sub GetAuthorityCode {
8881 #** @method scalar GetAuthorityName($target_key)
8886 sub GetAuthorityName {
8889 #** @method GetAxesCount()
8894 #** @method GetAxisMappingStrategy()
8896 sub GetAxisMappingStrategy {
8899 #** @method GetAxisName()
8904 #** @method GetAxisOrientation()
8906 sub GetAxisOrientation {
8909 #** @method GetCoordinateEpoch()
8911 sub GetCoordinateEpoch {
8914 #** @method GetDataAxisToSRSAxisMapping()
8916 sub GetDataAxisToSRSAxisMapping {
8919 #** @method GetInvFlattening()
8922 sub GetInvFlattening {
8925 #** @method scalar GetLinearUnits()
8929 sub GetLinearUnits {
8932 #** @method scalar GetLinearUnitsName()
8936 sub GetLinearUnitsName {
8939 #** @method GetName()
8944 #** @method scalar GetNormProjParm($name, $default_val = 0.0)
8947 # @param default_val
8950 sub GetNormProjParm {
8953 #** @method scalar GetProjParm($name, $default_val = 0.0)
8956 # @param default_val
8962 #** @method GetSemiMajor()
8968 #** @method GetSemiMinor()
8974 #** @method GetTOWGS84()
8976 # @return array = ($p1, $p2, $p3, $p4, $p5, $p6, $p7)
8981 #** @method GetTargetLinearUnits()
8983 sub GetTargetLinearUnits {
8986 #** @method GetUTMZone()
8988 # Get UTM zone information.
8989 # @return The UTM zone (integer). In scalar context the returned value
8990 # is negative for southern hemisphere zones. In list context returns
8991 # two values ($zone, $north), where $zone is always non-negative and
8992 # $north is true or false.
8996 my $zone = _GetUTMZone($self);
9003 return ($zone, $north);
9009 #** @method HasTOWGS84()
9014 #** @method ImportFromOzi()
9019 #** @method scalar IsCompound()
9026 #** @method IsDerivedGeographic()
9028 sub IsDerivedGeographic {
9031 #** @method IsDynamic()
9036 #** @method scalar IsGeocentric()
9043 #** @method scalar IsGeographic()
9050 #** @method scalar IsLocal()
9057 #** @method scalar IsProjected()
9064 #** @method scalar IsSame($rs)
9066 # @param rs a Geo::OSR::SpatialReference object
9072 #** @method scalar IsSameGeogCS($rs)
9074 # @param rs a Geo::OSR::SpatialReference object
9080 #** @method scalar IsSameVertCS($rs)
9082 # @param rs a Geo::OSR::SpatialReference object
9088 #** @method scalar IsVertical()
9095 #** @method MorphFromESRI()
9101 #** @method MorphToESRI()
9107 #** @method PromoteTo3D()
9112 #** @method Set(%params)
9114 # Set a parameter or parameters in the spatial reference object.
9115 # @param params Named parameters. Recognized keys and respective
9116 # values are the following.
9117 # - Authority: authority name (give also TargetKey, Node and Code)
9119 # - Node: partial or complete path to the target node (Node and Value together sets an attribute value)
9120 # - Code: code for value with an authority
9121 # - Value: value to be assigned to a node, a projection parameter or an object
9122 # - AngularUnits: angular units for the geographic coordinate system (give also Value) (one of Geo::OSR::LinearUnits)
9123 # - LinearUnits: linear units for the target node or the object (give also Value and optionally Node) (one of Geo::OSR::LinearUnits)
9124 # - Parameter: projection parameter to set (give also Value and Normalized) (one of Geo::OSR::Parameters)
9125 # - Normalized: set to true to indicate that the Value argument is in "normalized" form
9126 # - Name: a well known name of a geographic coordinate system (e.g. WGS84)
9127 # - GuessFrom: arbitrary text that specifies a projection ("user input")
9128 # - LOCAL_CS: name of a local coordinate system
9129 # - GeocentricCS: name of a geocentric coordinate system
9130 # - VerticalCS: name of a vertical coordinate system (give also Datum and optionally VertDatumType [default is 2005])
9131 # - Datum: a known (OGC or EPSG) name (or(?) one of Geo::OSR::Datums)
9132 # - CoordinateSystem: 'WGS', 'UTM', 'State Plane', or a user visible name (give optionally also Parameters, Zone, North, NAD83, UnitName, UnitConversionFactor, Datum, Spheroid, HorizontalCS, and/or VerticalCS
9133 # - Parameters: a reference to a list containing the coordinate system or projection parameters
9134 # - Zone: zone for setting up UTM or State Plane coordinate systems (State Plane zone in USGS numbering scheme)
9135 # - North: set false for southern hemisphere
9136 # - NAD83: set false if the NAD27 zone definition should be used instead of NAD83
9137 # - UnitName: to override the legal definition for a zone
9138 # - UnitConversionFactor: to override the legal definition for a zone
9139 # - Spheroid: user visible name
9140 # - HorizontalCS: Horizontal coordinate system name
9141 # - Projection: name of a projection, one of Geo::OSR::Projections (give also optionally Parameters and Variant)
9143 # @note Numerous Set* methods also exist but are not documented here.
9146 my($self, %params) = @_;
9147 if (exists $params{Authority} and exists $params{TargetKey} and exists $params{Node} and exists $params{Code}) {
9148 SetAuthority($self, $params{TargetKey}, $params{Authority}, $params{Code});
9149 } elsif (exists $params{Node} and exists $params{Value}) {
9150 SetAttrValue($self, $params{Node}, $params{Value});
9151 } elsif (exists $params{AngularUnits} and exists $params{Value}) {
9152 SetAngularUnits($self, $params{AngularUnits}, $params{Value});
9153 } elsif (exists $params{LinearUnits} and exists $params{Node} and exists $params{Value}) {
9154 SetTargetLinearUnits($self, $params{Node}, $params{LinearUnits}, $params{Value});
9155 } elsif (exists $params{LinearUnits} and exists $params{Value}) {
9156 SetLinearUnitsAndUpdateParameters($self, $params{LinearUnits}, $params{Value});
9157 } elsif ($params{Parameter} and exists $params{Value}) {
9158 error(1, $params{Parameter}, \%Geo::OSR::PARAMETERS) unless exists $Geo::OSR::PARAMETERS{$params{Parameter}};
9159 $params{Normalized} ?
9160 SetNormProjParm($self, $params{Parameter}, $params{Value}) :
9161 SetProjParm($self, $params{Parameter}, $params{Value});
9162 } elsif (exists $params{Name}) {
9163 SetWellKnownGeogCS($self, $params{Name});
9164 } elsif (exists $params{GuessFrom}) {
9165 SetFromUserInput($self, $params{GuessFrom});
9166 } elsif (exists $params{LOCAL_CS}) {
9167 SetLocalCS($self, $params{LOCAL_CS});
9168 } elsif (exists $params{GeocentricCS}) {
9169 SetGeocCS($self, $params{GeocentricCS});
9170 } elsif (exists $params{VerticalCS} and $params{Datum}) {
9171 my $type = $params{VertDatumType} || 2005;
9172 SetVertCS($self, $params{VerticalCS}, $params{Datum}, $type);
9173 } elsif (exists $params{CoordinateSystem}) {
9174 my @parameters = ();
9175 @parameters = @{$params{Parameters}}
if ref($params{Parameters});
9176 if ($params{CoordinateSystem} eq
'State Plane' and exists $params{Zone}) {
9177 my $NAD83 = exists $params{NAD83} ? $params{NAD83} : 1;
9178 my $name = exists $params{UnitName} ? $params{UnitName} : undef;
9179 my $c = exists $params{UnitConversionFactor} ? $params{UnitConversionFactor} : 0.0;
9180 SetStatePlane($self, $params{Zone}, $NAD83, $name, $c);
9181 } elsif ($params{CoordinateSystem} eq
'UTM' and exists $params{Zone} and exists $params{North}) {
9182 my $north = exists $params{North} ? $params{North} : 1;
9183 SetUTM($self, $params{Zone}, $north);
9184 } elsif ($params{CoordinateSystem} eq
'WGS') {
9185 SetTOWGS84($self, @parameters);
9186 } elsif ($params{CoordinateSystem} and $params{Datum} and $params{Spheroid}) {
9187 SetGeogCS($self, $params{CoordinateSystem}, $params{Datum}, $params{Spheroid}, @parameters);
9188 } elsif ($params{CoordinateSystem} and $params{HorizontalCS} and $params{VerticalCS}) {
9189 SetCompoundCS($self, $params{CoordinateSystem}, $params{HorizontalCS}, $params{VerticalCS});
9191 SetProjCS($self, $params{CoordinateSystem});
9193 } elsif (exists $params{Projection}) {
9194 error(1, $params{Projection}, \%Geo::OSR::PROJECTIONS) unless exists $Geo::OSR::PROJECTIONS{$params{Projection}};
9195 my @parameters = ();
9196 @parameters = @{$params{Parameters}}
if ref($params{Parameters});
9197 if ($params{Projection} eq
'Albers_Conic_Equal_Area') {
9198 SetACEA($self, @parameters);
9199 } elsif ($params{Projection} eq
'Azimuthal_Equidistant') {
9200 SetAE($self, @parameters);
9201 } elsif ($params{Projection} eq
'Bonne') {
9202 SetBonne($self, @parameters);
9203 } elsif ($params{Projection} eq
'Cylindrical_Equal_Area') {
9204 SetCEA($self, @parameters);
9205 } elsif ($params{Projection} eq
'Cassini_Soldner') {
9206 SetCS($self, @parameters);
9207 } elsif ($params{Projection} eq
'Equidistant_Conic') {
9208 SetEC($self, @parameters);
9209 # Eckert_I, Eckert_II, Eckert_III, Eckert_V ?
9210 } elsif ($params{Projection} eq
'Eckert_IV') {
9211 SetEckertIV($self, @parameters);
9212 } elsif ($params{Projection} eq
'Eckert_VI') {
9213 SetEckertVI($self, @parameters);
9214 } elsif ($params{Projection} eq
'Equirectangular') {
9216 SetEquirectangular($self, @parameters) :
9217 SetEquirectangular2($self, @parameters);
9218 } elsif ($params{Projection} eq
'Gauss_Schreiber_Transverse_Mercator') {
9219 SetGaussSchreiberTMercator($self, @parameters);
9220 } elsif ($params{Projection} eq
'Gall_Stereographic') {
9221 SetGS($self, @parameters);
9222 } elsif ($params{Projection} eq
'Goode_Homolosine') {
9223 SetGH($self, @parameters);
9224 } elsif ($params{Projection} eq
'Interrupted_Goode_Homolosine') {
9226 } elsif ($params{Projection} eq
'Geostationary_Satellite') {
9227 SetGEOS($self, @parameters);
9228 } elsif ($params{Projection} eq
'Gnomonic') {
9229 SetGnomonic($self, @parameters);
9230 } elsif ($params{Projection} eq
'Hotine_Oblique_Mercator') {
9231 # Hotine_Oblique_Mercator_Azimuth_Center ?
9232 SetHOM($self, @parameters);
9233 } elsif ($params{Projection} eq
'Hotine_Oblique_Mercator_Two_Point_Natural_Origin') {
9234 SetHOM2PNO($self, @parameters);
9235 } elsif ($params{Projection} eq
'Krovak') {
9236 SetKrovak($self, @parameters);
9237 } elsif ($params{Projection} eq
'Lambert_Azimuthal_Equal_Area') {
9238 SetLAEA($self, @parameters);
9239 } elsif ($params{Projection} eq
'Lambert_Conformal_Conic_2SP') {
9240 SetLCC($self, @parameters);
9241 } elsif ($params{Projection} eq
'Lambert_Conformal_Conic_1SP') {
9242 SetLCC1SP($self, @parameters);
9243 } elsif ($params{Projection} eq
'Lambert_Conformal_Conic_2SP_Belgium') {
9244 SetLCCB($self, @parameters);
9245 } elsif ($params{Projection} eq
'miller_cylindrical') {
9246 SetMC($self, @parameters);
9247 } elsif ($params{Projection} =~ /^Mercator/) {
9248 # Mercator_1SP, Mercator_2SP, Mercator_Auxiliary_Sphere ?
9249 # variant is in Variant (or Name)
9250 SetMercator($self, @parameters);
9251 } elsif ($params{Projection} eq
'Mollweide') {
9252 SetMollweide($self, @parameters);
9253 } elsif ($params{Projection} eq
'New_Zealand_Map_Grid') {
9254 SetNZMG($self, @parameters);
9255 } elsif ($params{Projection} eq
'Oblique_Stereographic') {
9256 SetOS($self, @parameters);
9257 } elsif ($params{Projection} eq
'Orthographic') {
9258 SetOrthographic($self, @parameters);
9259 } elsif ($params{Projection} eq
'Polyconic') {
9260 SetPolyconic($self, @parameters);
9261 } elsif ($params{Projection} eq
'Polar_Stereographic') {
9262 SetPS($self, @parameters);
9263 } elsif ($params{Projection} eq
'Robinson') {
9264 SetRobinson($self, @parameters);
9265 } elsif ($params{Projection} eq
'Sinusoidal') {
9266 SetSinusoidal($self, @parameters);
9267 } elsif ($params{Projection} eq
'Stereographic') {
9268 SetStereographic($self, @parameters);
9269 } elsif ($params{Projection} eq
'Swiss_Oblique_Cylindrical') {
9270 SetSOC($self, @parameters);
9271 } elsif ($params{Projection} eq
'Transverse_Mercator_South_Orientated') {
9272 SetTMSO($self, @parameters);
9273 } elsif ($params{Projection} =~ /^Transverse_Mercator/) {
9274 my($variant) = $params{Projection} =~ /^Transverse_Mercator_(\w+)/;
9277 SetTMVariant($self, $variant, @parameters) :
9278 SetTM($self, @parameters);
9279 } elsif ($params{Projection} eq
'Tunisia_Mining_Grid') {
9280 SetTMG($self, @parameters);
9281 } elsif ($params{Projection} eq
'VanDerGrinten') {
9282 SetVDG($self, @parameters);
9284 # Aitoff, Craster_Parabolic, International_Map_of_the_World_Polyconic, Laborde_Oblique_Mercator
9285 # Loximuthal, Miller_Cylindrical, Quadrilateralized_Spherical_Cube, Quartic_Authalic, Two_Point_Equidistant
9286 # Wagner_I, Wagner_II, Wagner_III, Wagner_IV, Wagner_V, Wagner_VI, Wagner_VII
9287 # Winkel_I, Winkel_II, Winkel_Tripel
9289 SetProjection($self, $params{Projection});
9292 error(
"Not enough information to create a spatial reference object.");
9296 #** @method SetAxisMappingStrategy()
9298 sub SetAxisMappingStrategy {
9301 #** @method SetCoordinateEpoch()
9303 sub SetCoordinateEpoch {
9306 #** @method SetDataAxisToSRSAxisMapping()
9308 sub SetDataAxisToSRSAxisMapping {
9311 #** @method SetMercator2SP()
9313 sub SetMercator2SP {
9316 #** @method SetVerticalPerspective()
9318 sub SetVerticalPerspective {
9321 #** @method Validate()
9327 #** @method Geo::OSR::SpatialReference new(%params)
9329 # Create a new spatial reference object using a named parameter. This
9330 # constructor recognizes the following key words (alternative in
9331 # parenthesis): WKT (Text), Proj4, ESRI, EPSG, EPSGA, PCI, USGS, GML
9332 # (XML), URL, ERMapper (ERM), MapInfoCS (MICoordSys). The value
9333 # depends on the key.
9334 # - WKT: Well Known Text string
9335 # - Proj4: PROJ.4 string
9336 # - ESRI: reference to a list of strings (contents of ESRI .prj file)
9337 # - EPSG: EPSG code number
9338 # - EPSGA: EPSG code number (the resulting CS will have EPSG preferred axis ordering)
9339 # - PCI: listref: [PCI_projection_string, Grid_units_code, [17 cs parameters]]
9340 # - USGS: listref: [Projection_system_code, Zone, [15 cs parameters], Datum_code, Format_flag]
9342 # - URL: URL for downloading the spatial reference from
9343 # - ERMapper: listref: [Projection, Datum, Units]
9344 # - MapInfoCS: MapInfo style coordinate system definition
9346 # For more information, consult the import methods in <a href="http://www.gdal.org/classOGRSpatialReference.html">OGR documentation</a>.
9348 # @note ImportFrom* methods also exist but are not documented here.
9352 # $sr = Geo::OSR::SpatialReference->new( key => value );
9354 # @return a new Geo::OSR::SpatialReference object
9359 my $self = Geo::OSRc::new_SpatialReference();
9360 if (exists $param{WKT}) {
9361 ImportFromWkt($self, $param{WKT});
9362 } elsif (exists $param{Text}) {
9363 ImportFromWkt($self, $param{Text});
9364 } elsif (exists $param{Proj4}) {
9365 ImportFromProj4($self, $param{Proj4});
9366 } elsif (exists $param{ESRI}) {
9367 ImportFromESRI($self, @{$param{ESRI}});
9368 } elsif (exists $param{EPSG}) {
9369 ImportFromEPSG($self, $param{EPSG});
9370 } elsif (exists $param{EPSGA}) {
9371 ImportFromEPSGA($self, $param{EPSGA});
9372 } elsif (exists $param{PCI}) {
9373 ImportFromPCI($self, @{$param{PCI}});
9374 } elsif (exists $param{USGS}) {
9375 ImportFromUSGS($self, @{$param{USGS}});
9376 } elsif (exists $param{XML}) {
9377 ImportFromXML($self, $param{XML});
9378 } elsif (exists $param{GML}) {
9379 ImportFromGML($self, $param{GML});
9380 } elsif (exists $param{URL}) {
9381 ImportFromUrl($self, $param{URL});
9382 } elsif (exists $param{ERMapper}) {
9383 ImportFromERM($self, @{$param{ERMapper}});
9384 } elsif (exists $param{ERM}) {
9385 ImportFromERM($self, @{$param{ERM}});
9386 } elsif (exists $param{MICoordSys}) {
9387 ImportFromMICoordSys($self, $param{MICoordSys});
9388 } elsif (exists $param{MapInfoCS}) {
9389 ImportFromMICoordSys($self, $param{MapInfoCS});
9390 } elsif (exists $param{WGS}) {
9392 SetWellKnownGeogCS($self,
'WGS'.$param{WGS});
9394 confess last_error() if $@;
9396 error(
"Unrecognized/missing parameters: @_.");
9398 bless $self, $pkg
if defined $self;
public Geo::GDAL::ColorTable ColorTable(scalar ColorTable)
A color table from a raster band or a color table, which can be used for a band.
public Geo::GDAL::ColorTable new(scalar GDALPaletteInterp='RGB')
A set of associated raster bands or vector layer source.
public Geo::GDAL::Band Band(scalar index)
A driver for a specific dataset format.
public Geo::GDAL::Dataset Create(hash params)
A rectangular area in projection coordinates: xmin, ymin, xmax, ymax.
public scalar Overlaps(scalar extent)
public Geo::GDAL::Extent new(array params)
An object, which holds meta data.
GDAL utility functions and a root class for raster classes.
public method VSIFFlushL()
public Geo::GDAL::Dataset OpenEx(hash params)
public scalar GetDataTypeSize(scalar DataType)
public scalar PackCharacter(scalar DataType)
public Geo::GDAL::Driver Driver(scalar Name)
Base class for geographical networks in GDAL.
The schema of a feature or a layer.
public Geo::OGR::FeatureDefn new(hash schema)
A collection of non-spatial and spatial attributes.
public list Tuple(array tuple)
public Geo::OGR::Feature new(hash schema)
Create a new feature.
A definition of a non-spatial attribute.
public Geo::OGR::FieldDefn new(hash params)
Create a new field definition.
A definition of a spatial attribute.
public Geo::OGR::GeomFieldDefn new(hash params)
Create a new spatial field definition.
public list GeometryTypes()
public array reference Points(arrayref points)
public method AddGeometry(scalar other)
public Geo::OGR::Geometry new(hash params)
A collection of similar features.
A spatial reference system.
public Geo::OSR::SpatialReference new(hash params)
Base class for projection related classes.