I'm trying to clip a csv-file containing xyz-data (points) by an irregular shaped polygon in ogr2ogr. My code runs without any errors or warnings, but it returns an exact copy of the input-csv. What am I doing wrong?

My code is: ogr2ogr -f CSV output.csv -clipsrc clip_polygon.shp -clipsrclayer clip_polygon input.vrt

The vrt-file looks like:

    <OGRVRTLayer name="test_layer">
       <GeometryField encoding="PointFromColumns" x="field_1" y="field_2" z="field_3"/>
  • Has the polygon shapefile the same CRS, and do the extents form ogrinfo and gdalinfo match?
    – AndreJ
    Apr 1, 2015 at 14:47
  • Yes, both the .shp as the .vrt have the same EPSG-code. When I visualise the .csv and and .shp in ArcGIS, it is clear that they both have the same spatial extent.
    – daarende
    Apr 2, 2015 at 8:59
  • I don't know if it makes a difference, but I put dst_datasource_name src_datasource_name always together behind the options. And I think to remember that csv, vrt and <OGRVRTLAYER name > should be the same.
    – AndreJ
    Apr 2, 2015 at 9:28
  • I'm experiencing the same issue. If I set the output data type to GeoJSON, it filters correctly by my -clipsrc. I can then convert that output back to CSV. Seems like bug. Oct 16, 2017 at 18:47

1 Answer 1


For some reason, adding -lco GEOMETRY=AS_WKT to my ogr2ogr command worked.

Here's my VRT (it's polygon data, not point):

        <OGRVRTLayer name="data">
            <SrcDataSource relativeToVRT="1">data.csv</SrcDataSource>
            <GeometryField encoding="WKT" field='field_1'/>

This ogr2ogr command didn't filter the input CSV at all: ogr2ogr -f CSV output.csv data.vrt -clipsrc -50.0 -10.0 -40.0 0.0

But this one did: ogr2ogr -f CSV output.csv data.vrt -clipsrc -50.0 -10.0 -40.0 0.0 -lco GEOMETRY=AS_WKT

No idea why a layer creation option (-lco) would have this affect, but it seems to be working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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