TransWikia.com

Does OWSLib have spatial filters?

Geographic Information Systems Asked by Ayaz49 on December 31, 2020

I am trying to apply spatial filter on a WFS layer, but owslib.fes has only BBox spatial filter. Other spatial filters such as Intersects, Disjoint, Contains etc. are missing and unable to find.
I want to apply intersect filter. I am able to do it in GeoServer.

Curl Request.

 curl -X POST -H "Content-Type:text/xml" --data @intersect.xml "https://demo.geo-solutions.it:443/geoserver/wfs"
         

@intersect.xml file.

       <wfs:GetFeature service="WFS" version="1.0.0"
             outputFormat="JSON"
          xmlns:topp="http://www.openplans.org/topp"
          xmlns:wfs="http://www.opengis.net/wfs"
          xmlns="http://www.opengis.net/ogc"
          xmlns:gml="http://www.opengis.net/gml"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.opengis.net/wfs
                              http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">
         <wfs:Query typeName="geosolutions:Linee_in_america">
            <Filter>
              <Intersects>
                <PropertyName>the_geom</PropertyName>
                  <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
                    <gml:coordinates>-74.817265,40.5296504</gml:coordinates>
                  </gml:Point>
                </Intersects>
              </Filter>
          </wfs:Query>
        <wfs:Query typeName="topp:states">
            <Filter>
              <Intersects>
                <PropertyName>the_geom</PropertyName>
                  <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
                    <gml:coordinates>-74.817265,40.5296504</gml:coordinates>
                  </gml:Point>
                </Intersects>
              </Filter>
          </wfs:Query>
        </wfs:GetFeature>

Is it possible to implement this using OWSLib??

One Answer

From the documentation https://geopython.github.io/OWSLib/#standards-support: OWSLib currently only support filter building for WFS 1.1 (FE.1.1). So OWSLib does support FE 1.1 filters and there is also an example about how to use PropertyIsLike filter. The challenge is to find the right syntax for the Intersects filter but once you get it right it should work. Maybe you can simple save the xml as you have it and use it like wfs11.getfeature(typename='bvv:gmd_ex', filter=filterxml).

>>> from owslib.fes import *
>>> from owslib.etree import etree
>>> from owslib.wfs import WebFeatureService
>>> wfs11 = WebFeatureService(url='http://geoserv.weichand.de:8080/geoserver/wfs', version='1.1.0')

>>> filter = PropertyIsLike(propertyname='bez_gem', literal='Ingolstadt', wildCard='*')
>>> filterxml = etree.tostring(filter.toXML()).decode("utf-8")
>>> response = wfs11.getfeature(typename='bvv:gmd_ex', filter=filterxml)

Answered by user30184 on December 31, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP