Dear Wangyal,

Well, with the Perl bindings you could do something like this (note: not tested code!). I'm assuming many things: the rasters are similar size, they are not too big so they fit into memory, etc.

use Modern::Perl;
use Geo::GDAL;

my ($admin,$lu) = @ARGV;

my $ds_admin = Geo::GDAL::Open($admin);
die "can't open $admin as a raster dataset" unless $ds_admin;

my $ds_lu = Geo::GDAL::Open($lu);
die "can't open $lu as a raster dataset" unless $ds_lu;

my $data_admin = $ds_admin->Band(1)->ReadTile;
my $data_lu = $ds_admin->Band(1)->ReadTile;

my %lu_at_admin; # will contain the number of cells of each land use in each admin area
for (my $y = 0; $y < @$data_admin-1; $y++) {
    my $row_admin = $data_admin->[$y];
    my $row_lu = $lu_admin->[$y];
    for (my $x = 0; $x < @$row_admin-1; $x++) {
        $lu_at_admin{$row_admin->[$x]}{$row_lu->[$x]}++;
    }
}

for my $admin (sort keys %lu_at_admin) {
    for my $lu (sort keys %{$lu_at_admin{$admin}}) {
say "There are $lu_at_admin{$admin}{$lu} cells of land use $lu in admin area $admin.";
    }
}

Best,

Ari Jolma

On 07.10.2015 23:12, Tsering W. Shawa wrote:
I am looking for a script to combine two raster data that have unique values. 
For example, one raster has administrative unit name and another has land cover 
data. I want to combine these two raster data to find a relationship between 
two data. I can do the same process in another GIS software but wanted to find 
an option to do this using gdal.

Any suggestion or help will be appreciated.

Thanks,
-Wangyal
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to