Skip to main content
corrected spelling, improved formatting
Source Link
nmtoken
  • 13.6k
  • 5
  • 38
  • 89

I'm trying to retrieve a list of all values from a raster layer (GeoTIFF) in geoserverGeoServer (2.5.x).

I tried to modify the code from http://trac.osgeo.org/openlayers/wiki/GetFeatureInfo but I can't seem to find a way to do this. I create a custom control that uses the OpenLayers.Handler.Box as input. This gives me back the right bounds (selected rectangle coordinates) but how do I send the bounds to geoserverGeoServer WMS?

I can code a pythonPython module to send the bounds to and extract the values from the raster and send it back to my webappweb application but I thought this must be possible from within OpenLayers?

Does anyone have an example of how do extract a range of values from a raster using GeoserverGeoServer and OpenlayersOpenLayers?

myMy code so far:

 function findLayerClick(event) {
    mouseLoc = map.getLonLatFromPixel(event.xy);
    layerlist = 'mylayer';
    //GetCoverage
    var url = sec.getFullRequestString({
                                        REQUEST: "GetFeatureInfo",
                                        EXCEPTIONS: "application/vnd.ogc.se_xml",
                                        BBOX: map.getExtent().toBBOX(),
                                        X: event.xy.x,
                                        Y: event.xy.y,
                                        INFO_FORMAT: 'text/plain',
                                        QUERY_LAYERS: layerlist,
                                        FEATURE_COUNT: 50,
                                        WIDTH: map.size.w,
                                        HEIGHT: map.size.h},
                                        "http://localhost:8080/geoserver/wms");
    
    var request = OpenLayers.Request.GET({
      url: url,
      callback: extractFeatures
    });
  }
  
  function extractFeatures(e) {
    console.log(e);
  }
function init() {
    wgs84 = new OpenLayers.Projection('EPSG:4326');
    googleProjection = new OpenLayers.Projection('EPSG:900913');var;
    
var options = {
      controls: [
                  new OpenLayers.Control.LayerSwitcher(),
                  new OpenLayers.Control.Navigation({zoomWheelEnabled: true, handleRightClicks: true}),
                  new OpenLayers.Control.PanZoom(),
                  new OpenLayers.Control.DragPan(),
                  new OpenLayers.Control.ScaleLine({maxWidth:200})
                ],
      
      div: 'map-canvas',
      theme: null,
      units: 'm',
      projection: googleProjection,
      displayProjection: wgs84,
      maxResolution: 'auto',
      
      eventListeners: {
          'movestart': function(e) {
          },
          'zoomend': function(e) {
              zoomBoxControl.deactivate();
          }
      }
    };
    
    map = new OpenLayers.Map(options);

    var ghyb = new OpenLayers.Layer.Google(
        "Google Physical",
        {
          type: google.maps.MapTypeId.TERRAIN,
          minZoomLevel: 1,
          numZoomLevels: 11,
          sphericalMercator: true,
          projection: 'EPSG:900913'
        }
    );

    //this is the raster layer
    sec = new OpenLayers.Layer.WMS(
      "mylayer",
      "http://localhost:8080/geoserver/wms",
      {layers: 'mylayer', format:'image/png', transparent:'true'},
      {opacity: 1.0, visibility: true, displayInLayerSwitcher: true, isBaseLayer: false}
    );
     
     OpenLayers.Util.extend(control, {
      draw: function () {
          this.drag = new OpenLayers.Handler.Box( control,
              {"done": this.notice},
              {keyMask: OpenLayers.Handler.MOD_CTRL});
          this.drag.activate();
      },
    
      notice: function (bounds) {
        mybounds = bounds;
        
        
        console.log(mybounds);
        
        var lowerLeft = map.getLonLatFromPixel(new OpenLayers.Pixel(mybounds.left, mybounds.bottom));
        var upperRight = map.getLonLatFromPixel(new OpenLayers.Pixel(mybounds.right, mybounds.top));
        
        mybounds = new OpenLayers.Bounds();
        mybounds.extend(lowerLeft);
        mybounds.extend(upperRight);
        
        //findLayerClick(mybounds);
        return(true);
      }
    });
  }

I'm trying to retrieve a list of all values from a raster layer (GeoTIFF) in geoserver (2.5.x).

I tried to modify the code from http://trac.osgeo.org/openlayers/wiki/GetFeatureInfo but I can't seem to find a way to do this. I create a custom control that uses the OpenLayers.Handler.Box as input. This gives me back the right bounds (selected rectangle coordinates) but how do I send the bounds to geoserver WMS?

I can code a python module to send the bounds to and extract the values from the raster and send it back to my webapp but I thought this must be possible from within OpenLayers?

Does anyone have an example of how do extract a range of values from a raster using Geoserver and Openlayers?

my code so far:

 function findLayerClick(event) {
    mouseLoc = map.getLonLatFromPixel(event.xy);
    layerlist = 'mylayer';
    //GetCoverage
    var url = sec.getFullRequestString({
                                        REQUEST: "GetFeatureInfo",
                                        EXCEPTIONS: "application/vnd.ogc.se_xml",
                                        BBOX: map.getExtent().toBBOX(),
                                        X: event.xy.x,
                                        Y: event.xy.y,
                                        INFO_FORMAT: 'text/plain',
                                        QUERY_LAYERS: layerlist,
                                        FEATURE_COUNT: 50,
                                        WIDTH: map.size.w,
                                        HEIGHT: map.size.h},
                                        "http://localhost:8080/geoserver/wms");
    
    var request = OpenLayers.Request.GET({
      url: url,
      callback: extractFeatures
    });
  }
  
  function extractFeatures(e) {
    console.log(e);
  }
function init() {
    wgs84 = new OpenLayers.Projection('EPSG:4326');
    googleProjection = new OpenLayers.Projection('EPSG:900913');var options = {
      controls: [
                  new OpenLayers.Control.LayerSwitcher(),
                  new OpenLayers.Control.Navigation({zoomWheelEnabled: true, handleRightClicks: true}),
                  new OpenLayers.Control.PanZoom(),
                  new OpenLayers.Control.DragPan(),
                  new OpenLayers.Control.ScaleLine({maxWidth:200})
                ],
      
      div: 'map-canvas',
      theme: null,
      units: 'm',
      projection: googleProjection,
      displayProjection: wgs84,
      maxResolution: 'auto',
      
      eventListeners: {
          'movestart': function(e) {
          },
          'zoomend': function(e) {
              zoomBoxControl.deactivate();
          }
      }
    };
    
    map = new OpenLayers.Map(options);

    var ghyb = new OpenLayers.Layer.Google(
        "Google Physical",
        {
          type: google.maps.MapTypeId.TERRAIN,
          minZoomLevel: 1,
          numZoomLevels: 11,
          sphericalMercator: true,
          projection: 'EPSG:900913'
        }
    );

    //this is the raster layer
    sec = new OpenLayers.Layer.WMS(
      "mylayer",
      "http://localhost:8080/geoserver/wms",
      {layers: 'mylayer', format:'image/png', transparent:'true'},
      {opacity: 1.0, visibility: true, displayInLayerSwitcher: true, isBaseLayer: false}
    );
     
     OpenLayers.Util.extend(control, {
      draw: function () {
          this.drag = new OpenLayers.Handler.Box( control,
              {"done": this.notice},
              {keyMask: OpenLayers.Handler.MOD_CTRL});
          this.drag.activate();
      },
    
      notice: function (bounds) {
        mybounds = bounds;
        
        
        console.log(mybounds);
        
        var lowerLeft = map.getLonLatFromPixel(new OpenLayers.Pixel(mybounds.left, mybounds.bottom));
        var upperRight = map.getLonLatFromPixel(new OpenLayers.Pixel(mybounds.right, mybounds.top));
        
        mybounds = new OpenLayers.Bounds();
        mybounds.extend(lowerLeft);
        mybounds.extend(upperRight);
        
        //findLayerClick(mybounds);
        return(true);
      }
    });
  }

I'm trying to retrieve a list of all values from a raster layer (GeoTIFF) in GeoServer (2.5.x).

I tried to modify the code from http://trac.osgeo.org/openlayers/wiki/GetFeatureInfo but I can't seem to find a way to do this. I create a custom control that uses the OpenLayers.Handler.Box as input. This gives me back the right bounds (selected rectangle coordinates) but how do I send the bounds to GeoServer WMS?

I can code a Python module to send the bounds to and extract the values from the raster and send it back to my web application but I thought this must be possible from within OpenLayers?

Does anyone have an example of how do extract a range of values from a raster using GeoServer and OpenLayers?

My code so far:

function findLayerClick(event) {
    mouseLoc = map.getLonLatFromPixel(event.xy);
    layerlist = 'mylayer';
    //GetCoverage
    var url = sec.getFullRequestString({
                                        REQUEST: "GetFeatureInfo",
                                        EXCEPTIONS: "application/vnd.ogc.se_xml",
                                        BBOX: map.getExtent().toBBOX(),
                                        X: event.xy.x,
                                        Y: event.xy.y,
                                        INFO_FORMAT: 'text/plain',
                                        QUERY_LAYERS: layerlist,
                                        FEATURE_COUNT: 50,
                                        WIDTH: map.size.w,
                                        HEIGHT: map.size.h},
                                        "http://localhost:8080/geoserver/wms");
    
    var request = OpenLayers.Request.GET({
      url: url,
      callback: extractFeatures
    });
  }
  
  function extractFeatures(e) {
    console.log(e);
  }
function init() {
    wgs84 = new OpenLayers.Projection('EPSG:4326');
    googleProjection = new OpenLayers.Projection('EPSG:900913');
    
var options = {
      controls: [
                  new OpenLayers.Control.LayerSwitcher(),
                  new OpenLayers.Control.Navigation({zoomWheelEnabled: true, handleRightClicks: true}),
                  new OpenLayers.Control.PanZoom(),
                  new OpenLayers.Control.DragPan(),
                  new OpenLayers.Control.ScaleLine({maxWidth:200})
                ],
      
      div: 'map-canvas',
      theme: null,
      units: 'm',
      projection: googleProjection,
      displayProjection: wgs84,
      maxResolution: 'auto',
      
      eventListeners: {
          'movestart': function(e) {
          },
          'zoomend': function(e) {
              zoomBoxControl.deactivate();
          }
      }
    };
    
    map = new OpenLayers.Map(options);

    var ghyb = new OpenLayers.Layer.Google(
        "Google Physical",
        {
          type: google.maps.MapTypeId.TERRAIN,
          minZoomLevel: 1,
          numZoomLevels: 11,
          sphericalMercator: true,
          projection: 'EPSG:900913'
        }
    );

    //this is the raster layer
    sec = new OpenLayers.Layer.WMS(
      "mylayer",
      "http://localhost:8080/geoserver/wms",
      {layers: 'mylayer', format:'image/png', transparent:'true'},
      {opacity: 1.0, visibility: true, displayInLayerSwitcher: true, isBaseLayer: false}
    );
     
     OpenLayers.Util.extend(control, {
      draw: function () {
          this.drag = new OpenLayers.Handler.Box( control,
              {"done": this.notice},
              {keyMask: OpenLayers.Handler.MOD_CTRL});
          this.drag.activate();
      },
    
      notice: function (bounds) {
        mybounds = bounds;
        
        
        console.log(mybounds);
        
        var lowerLeft = map.getLonLatFromPixel(new OpenLayers.Pixel(mybounds.left, mybounds.bottom));
        var upperRight = map.getLonLatFromPixel(new OpenLayers.Pixel(mybounds.right, mybounds.top));
        
        mybounds = new OpenLayers.Bounds();
        mybounds.extend(lowerLeft);
        mybounds.extend(upperRight);
        
        //findLayerClick(mybounds);
        return(true);
      }
    });
  }
Tweeted twitter.com/StackGIS/status/924069306790502400

Retrieve list of all features and values from raster layer (GeoserverGeoServer and OpenlayersOpenLayers2)

I tried to modify the code from http://trac.osgeo.org/openlayers/wiki/GetFeatureInfo but I can't seem to find a way to do this. I create a custom control that uses the OpenLayers.Handler.BoxOpenLayers.Handler.Box as input. This gives me back the right bounds (selected rectangle coordinates) but how do I send the bounds to geoserver WMS?

I can code a python module to send the bounds to and extract the values from the raster and send it back to my webapp but I thought this must be possible from within OpenlayersOpenLayers?

The findLayerClickfindLayerClick function returns back a valid value of a clicked pixel but i need the list (table, array or whatever) of values in the selected range. Hope someone can help me.

Thanks

Retrieve list of all features and values from raster layer (Geoserver and Openlayers)

I tried to modify the code from http://trac.osgeo.org/openlayers/wiki/GetFeatureInfo but I can't seem to find a way to do this. I create a custom control that uses the OpenLayers.Handler.Box as input. This gives me back the right bounds (selected rectangle coordinates) but how do I send the bounds to geoserver WMS?

I can code a python module to send the bounds to and extract the values from the raster and send it back to my webapp but I thought this must be possible from within Openlayers?

The findLayerClick function returns back a valid value of a clicked pixel but i need the list (table, array or whatever) of values in the selected range. Hope someone can help me.

Thanks

Retrieve list of all features and values from raster layer (GeoServer and OpenLayers2)

I tried to modify the code from http://trac.osgeo.org/openlayers/wiki/GetFeatureInfo but I can't seem to find a way to do this. I create a custom control that uses the OpenLayers.Handler.Box as input. This gives me back the right bounds (selected rectangle coordinates) but how do I send the bounds to geoserver WMS?

I can code a python module to send the bounds to and extract the values from the raster and send it back to my webapp but I thought this must be possible from within OpenLayers?

The findLayerClick function returns back a valid value of a clicked pixel but i need the list (table, array or whatever) of values in the selected range. Hope someone can help me.

Source Link
Loki
  • 79
  • 2

Retrieve list of all features and values from raster layer (Geoserver and Openlayers)

I'm trying to retrieve a list of all values from a raster layer (GeoTIFF) in geoserver (2.5.x).

I tried to modify the code from http://trac.osgeo.org/openlayers/wiki/GetFeatureInfo but I can't seem to find a way to do this. I create a custom control that uses the OpenLayers.Handler.Box as input. This gives me back the right bounds (selected rectangle coordinates) but how do I send the bounds to geoserver WMS?

I can code a python module to send the bounds to and extract the values from the raster and send it back to my webapp but I thought this must be possible from within Openlayers?

Does anyone have an example of how do extract a range of values from a raster using Geoserver and Openlayers?

my code so far:

 function findLayerClick(event) {
    mouseLoc = map.getLonLatFromPixel(event.xy);
    layerlist = 'mylayer';
    //GetCoverage
    var url = sec.getFullRequestString({
                                        REQUEST: "GetFeatureInfo",
                                        EXCEPTIONS: "application/vnd.ogc.se_xml",
                                        BBOX: map.getExtent().toBBOX(),
                                        X: event.xy.x,
                                        Y: event.xy.y,
                                        INFO_FORMAT: 'text/plain',
                                        QUERY_LAYERS: layerlist,
                                        FEATURE_COUNT: 50,
                                        WIDTH: map.size.w,
                                        HEIGHT: map.size.h},
                                        "http://localhost:8080/geoserver/wms");
    
    var request = OpenLayers.Request.GET({
      url: url,
      callback: extractFeatures
    });
  }
  
  function extractFeatures(e) {
    console.log(e);
  }

My map, layers, and the control handling the box select:

function init() {
    wgs84 = new OpenLayers.Projection('EPSG:4326');
    googleProjection = new OpenLayers.Projection('EPSG:900913');var options = {
      controls: [
                  new OpenLayers.Control.LayerSwitcher(),
                  new OpenLayers.Control.Navigation({zoomWheelEnabled: true, handleRightClicks: true}),
                  new OpenLayers.Control.PanZoom(),
                  new OpenLayers.Control.DragPan(),
                  new OpenLayers.Control.ScaleLine({maxWidth:200})
                ],
      
      div: 'map-canvas',
      theme: null,
      units: 'm',
      projection: googleProjection,
      displayProjection: wgs84,
      maxResolution: 'auto',
      
      eventListeners: {
          'movestart': function(e) {
          },
          'zoomend': function(e) {
              zoomBoxControl.deactivate();
          }
      }
    };
    
    map = new OpenLayers.Map(options);

    var ghyb = new OpenLayers.Layer.Google(
        "Google Physical",
        {
          type: google.maps.MapTypeId.TERRAIN,
          minZoomLevel: 1,
          numZoomLevels: 11,
          sphericalMercator: true,
          projection: 'EPSG:900913'
        }
    );

    //this is the raster layer
    sec = new OpenLayers.Layer.WMS(
      "mylayer",
      "http://localhost:8080/geoserver/wms",
      {layers: 'mylayer', format:'image/png', transparent:'true'},
      {opacity: 1.0, visibility: true, displayInLayerSwitcher: true, isBaseLayer: false}
    );
     
     OpenLayers.Util.extend(control, {
      draw: function () {
          this.drag = new OpenLayers.Handler.Box( control,
              {"done": this.notice},
              {keyMask: OpenLayers.Handler.MOD_CTRL});
          this.drag.activate();
      },
    
      notice: function (bounds) {
        mybounds = bounds;
        
        
        console.log(mybounds);
        
        var lowerLeft = map.getLonLatFromPixel(new OpenLayers.Pixel(mybounds.left, mybounds.bottom));
        var upperRight = map.getLonLatFromPixel(new OpenLayers.Pixel(mybounds.right, mybounds.top));
        
        mybounds = new OpenLayers.Bounds();
        mybounds.extend(lowerLeft);
        mybounds.extend(upperRight);
        
        //findLayerClick(mybounds);
        return(true);
      }
    });
  }

The findLayerClick function returns back a valid value of a clicked pixel but i need the list (table, array or whatever) of values in the selected range. Hope someone can help me.

Thanks