0

I have an Esri WMS server serving raster data. I can query this using OpenLayers TileWMS, all appears beautifully on my basemap.

I need to be able to query the WMS based on a polygon and display my rasters returned but for the life of me I can't work out how.

I can query on my extent using bbox nice and easily (out of the box). I can query the WMS using my polygon (hand drawn polygon) and get a list of object ID's back. I can use those object ID's and make a WMS request to get back JSON that contains href and the extent of the raster tile.

I am worried I am being stupid and perhaps overthinking this, but how can I get OpenLayers (5 currently) to display said image on my basemap from this GeoJSON?

To confirm, I want to display all rasters that appear geospatially inside a hand drawn polygon within my extent.

3
  • This example uses ESRI WMS layers equipyrene.org/ign2/esri2.php?a=ALL
    – Mapperz
    Jan 17, 2020 at 22:34
  • 2
    It would be helpful if you would include relevant part of your existing code and then explain what works and what does not work.
    – TomazicM
    Jan 18, 2020 at 8:20
  • display all rasters and Querying, as in the title, are different things
    – nmtoken
    Jan 19, 2020 at 13:34

1 Answer 1

2

I need to be able to query the WMS based on a polygon

You can only query A WMS at a point location, via a GetFeatureInfo operation.

If you only want a certain area, only specify that as BBOX in a GetMap operation.

If you want to resymbolize the map based on some query, use a custom SLD in the GetMap.

It's all possible in OpenLayers

To confirm, what I am looking for is to display on my map, all Raster that fall inside a complex polygon.

It's not possible in a WMS operation to fetch a map using anything other than a simple BBOX. If the GetFeatureInfo (query on a point in a map) returns GeoJSON for the original vector data, then you will need to manipulate that directly in OpenLayers to get some display.

If you want a raster from the returned GeoJSON you will need to create it somehow. It should be noted that when a geometry is returned as part of a GetFeatureInfo request (for example in GeoJSON) it is the geometry of the feature (at the point clicked), not the geometry of feature clipped to the map of the GetMap request. Other features in the BBOX are also not returned.

If you want to fetch data using a complex polygon, you'll need a WFS.

2
  • Thank you, using bbox for Getmap would not work as I need to only display rasters that fall within a complex polygon and not a 4 coord box. Querying on point location would not work as I would need to send too many requests to be fair on a client. Resymbolising, newbie here doesnt understand so i will take a look. Apologies for what is now clear to me as a vague question.
    – Phish
    Jan 19, 2020 at 17:56
  • To confirm, what I am looking for is to display on my map, all Raster that fall inside a complex polygon.
    – Phish
    Jan 19, 2020 at 17:57

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