in reply to Re: Interpolating data using pdl
in thread Interpolating data using pdl

Many thanks for the solution.

I might be able to use this. Can you also help me with the further processing?

The data-values can be categorized into three ranges and now i have a pdl with data for each point(pixel) of the map(as described here). And now i have to plot these points onto a image, with different colors based on the ranges. Can you provide a script for generating such image.

Replies are listed 'Best First'.
Re^3: Interpolating data using pdl
by vr (Curate) on Mar 15, 2017 at 17:11 UTC

    Actually, looking back at results in my answer, this bilinear is "somewhat" strange (and other interpolation methods are probably useless for the given task).

    pdl> $x = sequence 3,3 pdl> $y = zeroes 5,5 pdl> bilin2d( $x, $y ) pdl> p $y [ [ 0 0.5 1 1.5 2] [1.5 2 2.5 3 3.5] [ 3 3.5 4 4.5 5] [4.5 5 5.5 6 6.5] [ 6 6.5 7 7.5 8] ]

    That's better now. We can even visualize it with mesh3d [$y].

    karthik248, it's not clear what kind of plot do you mean? 3-D? Over-impose some visualization onto a world map? Or just 2-D image with 3 different colors?

      Thanks for the update. I meant a 2-D image with RGB or ARGB.
        use strict; use warnings; use PDL; use PDL::IO::Image; # data my $x = sequence( 100, 100 ); # ranges my $range1 = $x < 3000; my $range2 = ( $x >= 3000 ) * ( $x <= 7000 ); my $range3 = $x > 7000; my $bytes = ( $range1 + 2 * $range2 + 3 * $range3 )-> byte; my $palette = byte [ [ 0, 0, 0 ], [ 255, 50, 50 ], [ 128, 255, 0 ], [ 255, 215, 0 ] ]; $bytes-> wimage( 'test.png', { palette => $palette });

        Not sure if I understand what you need, but, "from the top of my head", this code produces rather dull looking image with three colorful stripes (no time to invent some "smart" data). You have your conditions, combine them, associate with palette of the same length + 1.