0

How to get the center point of a line using ogr2ogr command line?

I am unable to get a proper script to get this work.

1

1 Answer 1

1

In theory it can be done by using ogr2ogr with SQL and SQLite dialect. Here is a test command for ogrinfo but the same -sql works also in ogr2ogr.

ogrinfo osm.sqlite -dialect sqlite -sql "select Line_Interpolate_Point(geometry,0.5) from lines limit 10"

Unfortunately the Line_Interpolate_Point function is very new in Spatialite and if GDAL is compiled with older spatialite version the result will be

ERROR 1: In ExecuteSQL(): sqlite3_prepare(select Line_Interpolate_Point(geometry,0.5) from lines lim it 10): no such function: Line_Interpolate_Point

if you do not manage to get a GDAL build that has built with a new enough spatialite you can convert your data into spatialite and run that SELECT with spatilite-gui v1.7.1.

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.