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

Add 'gdal vector clip' and 'gdal vector pipeline read ... ! clip ... ! write ...' #11681

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

rouault
Copy link
Member

@rouault rouault commented Jan 17, 2025

No description provided.

@rouault rouault added funded through GSP Work funded through the GDAL Sponsorship Program gdal_cli Anything related to the new 3.11 "gdal" CLI frontend labels Jan 17, 2025
@rouault rouault added this to the 3.11.0 milestone Jan 17, 2025
@coveralls
Copy link
Collaborator

coveralls commented Jan 17, 2025

Coverage Status

coverage: 70.064% (+0.007%) from 70.057%
when pulling cdb3f1e on rouault:vector_clip
into 8f576c0 on OSGeo:master.

@rouault
Copy link
Member Author

rouault commented Jan 20, 2025

@sgillies @jratike80 Thoughts ? Cf https://gdal--11681.org.readthedocs.build/en/11681/programs/gdal_vector_clip.html for the options. I've tried to be as much consistent as possible with the raster clip (https://gdal--11681.org.readthedocs.build/en/11681/programs/gdal_raster_clip.html) although the later only currently accepts raster 'like' datasets, whereas for this vector clip I accept both raster and vector. For raster, accepting a vector like could imply doing more than just rectangular clipping, and potentially something similar to gdalwarp -cutline

@jratike80
Copy link
Collaborator

Thoughts?

I would add a couple of words somewhere and explain that clip often yields mixed geometry types. And add -nlt GEOMETRY into the GeoPackage example. Do I remember right, that -nlt then affects all output layers? Alternatively there could be an option to filter the output by geometry type, but it might become a black box that user cannot control and understand.

If the specified dataset is a vector dataset, its polygonal geometries are unioned together to form the clipping geometry.

Idea is OK, but polygon layers tend to be dirty with gaps and overlaps between individual polygon features. The clipped result may be surprising. Users should be warned.

For raster, accepting a vector like could imply doing more than just rectangular clipping, and potentially something similar to gdalwarp -cutline

Maybe also similar to gdal_rasterize -i for clipping holes. They would be nice options to have in the future. For the raster --like, maybe mention that bounds which are taken from the template image are rectangular, and bounds include nodata.

@rouault
Copy link
Member Author

rouault commented Jan 20, 2025

Thanks @jratike80 for the feedback

I would add a couple of words somewhere and explain that clip often yields mixed geometry types. And add -nlt GEOMETRY into the GeoPackage example

Some words added (as well as improving the code). Currently we don't have any equivalent of -nlt with "gdal" utility. We probably need some "geom_op" step to "gdal vector pipeline" to do such thing, and other operations like buffering, densifying, etc. Or a distinct step per geometry operation... (although I'm a bit afraid of the doc and code overhead of having one step per type of geometry operation)

Idea is OK, but polygon layers tend to be dirty with gaps and overlaps between individual polygon features. The clipped result may be surprising

That's what we do already with ogr2ogr. Warning added

@rouault rouault merged commit 4ac60a5 into OSGeo:master Jan 21, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
funded through GSP Work funded through the GDAL Sponsorship Program gdal_cli Anything related to the new 3.11 "gdal" CLI frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants