pyrsgis.raster.clip_file¶
- pyrsgis.raster.clip_file(file, x_min, x_max, y_min, y_max, outfile=None)[source]¶
Clip and export raster file in one go
This function can clip a raster file by using minimum and maximum latitude and longitude values. This function builds on the
pyrsgis.raster.clip
function.- Parameters
- filestring
Input file name or path to clip.
- x_mininteger or float
The lower longitude value.
- x_maxinteger or float
The upper longitude value.
- y_mininteger or float
The lower latitude value.
- y_maxinteger or float
The upper latitude value.
- outfilestring
Name or path to store the clipped raster file.
Examples
>>> from pyrsgis import raster >>> infile = r'E:/path_to_your_file/your_file.tif' >>> outfile = r'E:/path_to_your_file/clipped_file.tif' >>> raster.clip_file(infile, x_min=770000, x_max=790000, y_min=1420000, y_max=1440000, outfile=outfile)
The catch here is that the user should be aware of and has to assign the minimum and maximum latitude and longitude values. If you are not sure of the extent to clip, you may want to first read the raster file, plot and find your area of interest and check the bounding box of the input raster. To do so, please check the
pyrsgis.raster.clip
function.