1

I have a .txt file that has all the features I want to select. It looks like this in the small version:

('100mN25991E46719','100mN25993E46718','100mN26000E46712','100mN26002E46691','100mN26003E46700','100mN26004E46705','100mN26004E46710','100mN26007E46705','100mN26008E46706','100mN26008E46707')

Here is the large (18.8 MB) version with all features: https://drive.google.com/file/d/1t5H4SpqyEZ6SsCOhCXMh-zoYSW4Nr467/view?usp=sharing

I want to subset this large! (2.8 GB) geopackage: https://data.statistik.gv.at/data/OGDEXT_RASTER_1_STATISTIK_AUSTRIA_LAEA_GPKG.zip

I found this StackOverflow answer: How to use gdal ogr2ogr to subset features by attributes stored in a csv? which does exactly what I want to do.

Yet, when I call:

cells_with_data=$(cat cells_with_data.txt)

ogr2ogr -sql "Select * from l000100 where cellcode IN $cells_with_data" ./output.gpkg STATISTIK_AUSTRIA_RASTER_LAEA_3035.gpkg

It works with the small input from above, however, when I use the 18.8 MB textfile with all all the codes I want to keep in the output, it throws this error:

zsh: argument list too long: ogr2ogr

Which first does not seem to me to be related to the size of the input, but for some reason it works with the smaller one...

Any idea what I might be doing wrong here?

4
  • 1
    Try the @filename syntax, but you're probably still going to run into a SQL limit rather than the commandline limit you hit.
    – user2856
    Jul 5, 2022 at 6:53
  • 2
    Note that the problem isn't coming from ogr2ogr. Its coming from zsh, which appears to object to you passing 18.8 MB of command line arguments.
    – BradHards
    Jul 9, 2022 at 11:39
  • got it! Thanks a lot:)
    – Lenn
    Jul 9, 2022 at 11:54
  • Please write that as an answer.
    – user30184
    Aug 1, 2022 at 13:31

0

Your Answer

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

Browse other questions tagged or ask your own question.