Problems reading a TIF file (newbie question)

Ray ray at SUSTAINABLE.IE
Tue Mar 22 08:03:40 PST 2005


I am having problems displaying a TIF file using PHP mapscript, I suspect
that the problem lies in the map file.

gdalinfo PAGE48.TIF (name of the file) gives:

Driver: GTiff/GeoTIFF
Size is 4724, 6300
Coordinate System is `'
Metadata:
  TIFFTAG_DOCUMENTNAME=JOB_NAME
TIFFTAG_IMAGEDESCRIPTION=DKB200:[OS50000.DUBGUIDE_4TH_MAPS]PAGE_CLIP_48.TIF;
  TIFFTAG_SOFTWARE=Barco Graphics - V9.2
  TIFFTAG_XRESOLUTION=600
  TIFFTAG_YRESOLUTION=600
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 6300.0)
Upper Right ( 4724.0,    0.0)
Lower Right ( 4724.0, 6300.0)
Center      ( 2362.0, 3150.0)
Band 1 Block=4724x8 Type=Byte, ColorInterp=Palette
  Color Table (RGB with 256 entries)
    0: 255,255,255,255
    1: 59,43,47,255
    2: 0,137,159,255

<...cut...>

  254: 255,255,255,255
  255: 255,255,255,255

I used the TAB file to get the map EXTENT and projection:

$ cat Page48.TAB
!table
!version 300
!charset WindowsLatin1

Definition Table
  File "./PAGE48.TIF"
  Type "RASTER"
  (318000,232000) (1,0) Label "Pt 1",
  (321000,232000) (4723,0) Label "Pt 2",
  (321000,228000) (4723,6296) Label "Pt 3",
  (318000,228000) (1,6295) Label "Pt 4"
  CoordSys Earth Projection 8, 42, "m", -8, 53.5, 1.000035, 200000, 250000
  Units "m"

I also have a TFW file:

$ cat Page48.TFW
0.635324015247776
0
0
-0.635324015247776
317999.682337992
231999.682337992

My MAP file looks like this:

MAP
  NAME PAGE48
  STATUS ON
  SIZE 472 630
  IMAGETYPE PNG
  EXTENT 318000 228000 321000 232000
  UNITS METERS
  FONTSET "./fonts/fonts.list"
  SHAPEPATH "./data/"
  IMAGECOLOR 15 158 120

  PROJECTION
    "proj=utm"
    "ellps=mod_airy"
    "lon_0=-8"
    "lat_0=53.5"
  END

  WEB
    IMAGEPATH "/var/www/html/mapscript/gmap-ms40/greenmap/test/"
    IMAGEURL "/mapscript/gmap-ms40/greenmap/test/"
  END

  LAYER
    DATA "./data/PAGE48.TIF"
    TYPE RASTER
  END

  LAYER
    NAME "test text"
    STATUS DEFAULT
    TRANSFORM FALSE
    TYPE ANNOTATION
    FEATURE
      POINTS
       60 10
      END
      TEXT "This text should appear at the top of the image."
    END
    CLASS
      LABEL
        TYPE truetype
        FONT arial
        SIZE 12
        POSITION CR
        COLOR 0 0 0
      END
    END
  END
END

And my code looks like this:

<?php

dl ("php_mapscript.so");

ms_ResetErrorList();

$map = ms_newMapObj ("greenmap.map");

$image = $map->draw();

$image_url = $image->saveWebImage(MS_PNG, 0, 0, -1);

$error = ms_GetErrorObj ();

print ("$error->code");

while ($error && $error->code != MS_NOERR)
  {
    printf ("Error in %s: %s<br>\n", $error->routine, $error->message);
    $error = $error->next();
  }

echo "<img src=$image_url width=$map->width height=$map->height>";

?>

I get a nice green background with the text as I expected, but I'd really
like to see the map too...

Any ideas about what I'm doing wrong gratefully received.

Thanks,

Ray



More information about the MapServer-users mailing list