[mapserver-users] Accessing raster cell values

Sven Schroeter schroeter at netgis.de
Thu May 29 05:44:36 EDT 2008


Hi,

if you have access to  the mapfile, you can make a queryByPoint  with
mapscript (i.e with an ajax-function)
You have to send your point-coordinats to the script like this:

$coord = split(',',$_POST["coord"]);
dl('php_mapscript.dll');

//load mapfile
$map= ms_newMapObj($mapfilepath.'\yourmap.map');

//create point
$qPoint = ms_newPointObj();
$qPoint->setXY($coord[0]*1,$coord[1]*1);

//set layer
$layer = $map->getLayerByName("your_rasterlayer");

//Pointquery (Single)
@$datQuery = $layer->queryByPoint($qPoint, MS_SINGLE, 1);

//if success
if ($datQuery == MS_SUCCESS) {
         for ($j=0; $j<$layer->getNumResults(); $j++) {
            $result = $layer->getResult($j);
   $layer->open();
   $shpobj = $layer->getShape($result->tileindex,$result->shapeindex);
   $attr = $shpobj->values;
   //echo round($attr["value_0"],2);
   $rasterdata = round($attr["value_0"],1);
   print 'My Data: '.$rasterdata.';
   $shpobj->free();
         }
     }
  else{
     print 'no Data';
  }

Greetings
Sven



----- Original Message ----- 
From: "Andrew Mason" <andrew at environ-it.co.uk>
To: <mapserver-users at lists.osgeo.org>
Sent: Thursday, May 29, 2008 10:29 AM
Subject: [mapserver-users] Accessing raster cell values


> Hello List,
>
> This question may be a general newbie GIS question and not solely  related 
> to Mapserver, so apologies if I'm posting to the wrong place.
>
> I am serving a GeoTiff via Mapserver using WMS, and displaying it  using 
> OpenLayers, so far so good.
> I need to be able to click on a point on the map and display the  value 
> held within that particular Raster cell.
> Can anyone suggest what mechanism I should use for this? WCS looks  like 
> it might be the thing I need, but I'm having difficulty finding  much in 
> the way of examples and instructions.
> I've followed what examples there are and all I can get Mapserver to 
> return using WCS, is a Geotiff with every pixel set to zero.
> So I've obviously not got it working correctly, and even if it were  I'm 
> not sure how to get the information I need out of the returned  Geotiff 
> when my client is OpenLayers.
>
> Can anyone suggest a way to access a raster's values when it is  served by 
> Mapserver and viewed using OpenLayers?
>
> Thank you
>
> Andrew Mason
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>




More information about the mapserver-users mailing list