Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to intersect a user defined polygon with a Point WMS Feature Layer. I am using the following code

action = new GeoExt.Action({
        text: "draw poly",
        control: new OpenLayers.Control.DrawFeature(
            features, OpenLayers.Handler.Polygon, {
            eventListeners: {
                "featureadded": function(evt) {
                    var pfilter = new OpenLayers.Filter.Spatial({
                             type: OpenLayers.Filter.Spatial.INTERSECTS,
                             value: evt.feature.geometry

        map: map,
        // button options
        toggleGroup: "draw",
        allowDepress: false,
        tooltip: "draw polygon",
        // check item options
        group: "draw"
    actions["draw_poly"] = action;

Now I do have the polygon geometry,

POLYGON((-12440279.225738 3759478.9686547,-12376683.618213 3731350.1422497,-12429272.293666 3708113.2856542,-12440279.225738 3759478.9686547)) { id=


, components=[1], bounds=-12440279.225738,3708113.2856542,-12376683.618213,3759478.9686547, more...}

But I am not sure how do I proceed from here? Pls help.

share|improve this question

Point WMS Feature Layer??? You can't analyse WMS layer. OpenLayers sees it as a bunch of png files. If WMS comes from Postgis you can send newly drawn polygon via AJAX to database and make intersection using source data.

share|improve this answer

If you want to stay in the standards based world (rather than rolling your own AJAX based protocol) then look at using a WFS to request the points from the server using a filter based on your polygon.

See for an example

share|improve this answer
I have updated my quetion. I am now using the WFS layer but having projection issues. Also once I WFS filtered, how using Geometry value: event.feature.geometry, how do I fetch the data of this filtered out WFS? – Sam007 Sep 20 '12 at 17:48
up vote 0 down vote accepted

It seems we can fetch the feature details using WFS.v1_1_0 for any WMS layer. So I assigned the WMS Layer as WFS Protocol,

wfsProtocol = new OpenLayers.Protocol.WFS.v1_1_0({
                         url: "http://domainname:8080/geoserver/wfs",
                         featureType: "PimaPine",
                         featureNS: "",
                         srsName: "EPSG:900913"

And then for the intersection use this WFS Protocol to fetch the data,{
                         filter: pfilter,
                         callback: processSpatialQuery,
                         scope: new OpenLayers.Strategy.BBOX()

This is much better way to fetch the data, as most of the time you will need to add WMS layer directly as the user requests it and then intersection using WFS protocol will fetch all the data you need.

Update: I found another simpler and faster way to do that,

wfsProtocol = new OpenLayers.Protocol.WFS.fromWMSLayer(WMSlayer);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.