I have a GeoJSON file that has bounding boxes (squares), and I also have many TIFF images. I want to crop the TIFF images exactly to bounding boxes provided by the GeoJSON file. While doing this, I want to preserve the coordinates of the TIFF images that is shown in QGIS. I searched a lot, but I could not find useful information about it.
As @user30184 has mentioned,
gdalwarp can perform exactly what you are looking for and can be called from the command line with the appropriate operations flags.
If you are working from python (as has been tagged) and all your data is in the proper coordinate systems, you might find the
fiona command line tools a bit simpler to handle. The operation that you are looking for is called
After installing both of those libraries, I would follow closely the example that the
rasterio documentation shows. Something along the lines of...
rio clip input.tif output.tif --bounds $(fio info my_geojson.json --bounds)
...for each input.tif (using a loop or manually entering each if you aren't comfortable with shell scripting) would give you the desired outcome.