I have a set of Digital Terrain Model ASCII grid files; they're the output of a LIDAR survey over our city, and so cover adjacent areas. Now I need to "cut" a polygon out of these files; this polygon is in GeoJSON format and can overlap across more than one of these DTM files.

Then the cut area should be put into a new ASCII grid file, because it needs to be passed to an existing program our team created, with the area outside the polygon.

Here is a diagram to give a more visual description.

Magic needed!

How can I execute this operation?

I have GDAL installed, and I have admin rights, so I can install any software I need. Of course it would be better if it was Open Source, but the most important things is that I will have to automate this operation next, so something that works from the command line or has a Python API would be ideal for me.

1 Answer 1


Without testing this might work.

1) Create a virtual mosaic from all your source files

gdalbuildvrt mosaic.vrt *.asc

2) Use gdalwarp and crop the mosaic to cutline

gdalwarp -of [your format] -cutline your_geojson.json -crop_to_cutline mosaic.vrt cropped_output.[ext].

You may need to give also the layer name for the GeoJSON cutline which is always "OGRGeoJSON".

  • This did work to generate GeoTIFFs and a few other files. Thanks! However, I can't generate the Ascii grid files I need. I tried using -of AAIGrid which is the type gdalinfo gives me for the source files, but I get a message saying that it's not recognized.
    – Btz
    Oct 21, 2016 at 15:25

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.