Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OGRVRTLayer layer level SrcRegion clip not implemented #11519

Open
tcommandeur opened this issue Dec 19, 2024 · 2 comments
Open

OGRVRTLayer layer level SrcRegion clip not implemented #11519

tcommandeur opened this issue Dec 19, 2024 · 2 comments

Comments

@tcommandeur
Copy link

What is the bug?

According to the documentation of VRT the SrcRegion on OGRVRTLayer should have a clip attribute.

SrcRegion (optional) : This element is used to define an initial spatial filter for the source features. This spatial filter will be combined with any spatial filter explicitly set on the VRT layer with the SetSpatialFilter() method. The value of the element must be a valid WKT string defining a polygon. An optional clip attribute can be set to "TRUE" to clip the geometries to the source region, otherwise the source geometries are not modified.

For the GeometryField the SrcRegion clip="true" is working but looking at the source code its not implemented for OGRVRTLayer.

Steps to reproduce the issue

Not working VRT for SrcRegion clip on VRTLayer

<OGRVRTDataSource>
    <OGRVRTLayer name="pand">
        <SrcDataSource>bag-light.gpkg</SrcDataSource>
        <SrcLayer>pand</SrcLayer>
        <LayerSRS>EPSG:28992</LayerSRS>
        <SrcRegion clip="true">POLYGON((120000 435000, 155000 435000, 155000 470000, 120000 470000, 120000 435000))</SrcRegion>
    </OGRVRTLayer>
</OGRVRTDataSource>

Working VRT for GeometryField

<OGRVRTDataSource>
    <OGRVRTLayer name="pand">
        <SrcDataSource>bag-light.gpkg</SrcDataSource>
        <SrcLayer>pand</SrcLayer>
        <LayerSRS>EPSG:28992</LayerSRS>
        <GeometryField>
            <!-- Clip is only implemented at GeometryField level and not at OGRVRTLayer level -->
            <SrcRegion clip="true">POLYGON((120000 435000, 155000 435000, 155000 470000, 120000 470000, 120000 435000))</SrcRegion>
        </GeometryField>
    </OGRVRTLayer>
</OGRVRTDataSource>

Versions and provenance

GDAL 3.6, 3.9.3, 3.10.0 self-built from binaries.

Additional context

No response

@jratike80
Copy link
Collaborator

jratike80 commented Dec 19, 2024

The documentation has this DataSource level example https://github.com/OSGeo/gdal/blob/42ca02ce9397ec3f37dcc46eace97011f1aa0d53/doc/source/drivers/vector/vrt.rst#example-transparent-spatial-filtering. Does it work?

<OGRVRTDataSource>
    <OGRVRTLayer name="source">
        <SrcDataSource>source.shp</SrcDataSource>
        <SrcRegion clip="true">POLYGON((0 40,10 40,10 50,0 50,0 40))</SrcRegion>
    </OGRVRTLayer>
</OGRVRTDataSource>

@jratike80
Copy link
Collaborator

I made a test with a geopackage, and SrcRegion really does work inside GeometryField, but outside that ogrinfo -al -so gives an error:

Feature Count: 152770
ERROR 1: Invalid geometry field index : -1
ERROR 1: Invalid geometry field index : -1


<OGRVRTDataSource>
  <OGRVRTLayer name="jarvi">
    <SrcDataSource relativeToVRT="1" shared="1">mtkmaasto.gpkg</SrcDataSource>
    <SrcLayer>jarvi</SrcLayer>
    <GeometryField>
    <SrcRegion clip="true">POLYGON (( 436151 6926630, 436151 6946458, 464022 6946458, 464022 6926630, 436151 6926630 ))</SrcRegion>
    </geometryField>
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants