WbW supports reading and writing many types of raster, vector, and LiDAR data formats.
import whitebox_workflows as wbw wbe = wbw.WbEnvironment() wbe.working_directory = 'path/containing/data/files' # Reading raster data my_raster = wbe.read_raster('file_name.tif') # Or read_rasters (with an 's') for multiple rasters at once... my_raster1, my_raster2 = wbe.read_rasters('file_name1.tif', 'file_name2.tif') # Writing raster data wbe.write_raster(my_raster, 'output.tif') # You can also ask WbW to compress the written raster wbe.write_raster(my_raster, 'output.tif', compress=True) # Only GeoTIFF compression is supported. # Reading vector data my_vector = wbe.read_vector('file_name.shp') my_vector1, my_vector2 = wbe.read_vectors('file_name1.shp', 'file_name2.shp') # Writing vector data wbe.write_vector(my_vector, 'output.shp') # Reading LiDAR data my_lidar = wbe.read_lidar('file_name.laz') my_lidar1, my_lidar2 = wbe.read_lidars('file_name1.laz', 'file_name2.laz') # Writing LiDAR data wbe.write_lidar(my_lidar, 'output.laz')
WbW can currently support reading/writing raster data in several common formats.
|Big GeoTIFF||*.tif, *.tiff||X||X|
|Esri ASCII||*.txt, *.asc||X||X|
|Esri BIL||*.bil, *.hdr||X||X|
|Esri Binary||*.flt and *.hdr||X||X|
|GRASS ASCII||*.txt, *.asc||X||X|
|Idrisi||*.rdc and *.rst||X||X|
|SAGA Binary||*.sdat and *.sgrd||X||X|
|Whitebox||*.tas and *.dep||X||X|
Throughout this manual code examples that manipulate raster files all use the GeoTIFF format (.tif) but any of the supported file extensions can be used in its place.
WbW is able to read GeoTIFFs compressed using the PackBits, DEFLATE, and LZW methods. Compressed GeoTIFFs, created using the DEFLATE algorithm, can also be output from any tool that generates raster output files by using
At present, there is limited support in WbW for working with vector geospatial data formats. The only supported vector format is the ESRI Shapefile. Shapefiles geometries (.shp) and attributes (.dbf) can be read and written.
While the Shapefile format is extremely common, it does have certain limitations for vector representation. For example, owing to their 32-bit indexing, Shapefiles are limited in the number of geometries that can be stored in these files. Furthermore, Shapefiles are incapable of storing geometries of more than one type (point, lines, polygons) within the same file. As such, the vector-related tools in WhiteboxTools also carry these same limitations imposed by the Shapefile format.