gridatb.to.arc.pl 652 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env perl
  2. if($#ARGV < 1 || $#ARGV == 2 || $#ARGV > 3 || $ARGV[0] =~ m/^-*help$/){
  3. print "Usage: gridatb.to.arc gridatb_file arc_file [xllcorner yllcorner]\n";
  4. exit;
  5. }
  6. $xllcorner = 0;
  7. $yllcorner = 0;
  8. if($#ARGV == 3){
  9. $xllcorner = $ARGV[2];
  10. $yllcorner = $ARGV[3];
  11. }
  12. open IN, $ARGV[0] or die;
  13. $title = <IN>;
  14. ($ncols, $nrows, $cellsize) = (<IN> =~ m/^[ \t]*([0-9.]+)[ \t]+([0-9.]+)[ \t]+([0-9.]+)[ \t]*$/);
  15. open OUT, ">$ARGV[1]" or die;
  16. print OUT <<EOT
  17. ncols $ncols
  18. nrows $nrows
  19. xllcorner $xllcorner
  20. yllcorner $yllcorner
  21. cellsize $cellsize
  22. NODATA_value 9999
  23. EOT
  24. ;
  25. while(<IN>){
  26. print OUT;
  27. }
  28. close IN;
  29. close OUT;