get_int_box ( area_box ) # lon and lat coords of the cut points/pixels wgs_84_box = geo_tiff.
There are also some helper methods to get the bounding box of the resulting cut array: # col and row indexes of the cut area int_box = geo_tiff. This will get 2 extra perimeters of points around the outside of the the area_box. To achieve this, use the outer_points param:Īrray = geo_tiff.read_box(area_box, outer_points=2) This may be useful if you want to interpolate to points near the area_box boundary. In some cases, you may want some extra points/pixels around the outside of your area_box. Note: For the area_box, use the same crs as as_crs. from geotiff import GeoTiff # in WGS 84 area_box = geo_tiff = GeoTiff ( tiff_file ) array = geo_tiff. WARNING: This will fail if the box you are using is too large and the data cannot fit into memory. In many cases, you are only interested in a section of the tiff. array ( zarr_array ) Read a section of a large tiff If you are confident that the data will fit into memory, you can convert it to a numpy array: import numpy as np array = np. This will return a zarr array as often geotiff files cannot fit into memory. get_wgs_84_coords ( i, j ) Read the data get_coords ( i, j ) # in WGS 84 coords geo_tiff. Get coordinates of a point/pixel: i = 5 j = 6 # in the as_crs coords geo_tiff. tif_bBox_wgs_84 # the bounding box in the as_crs converted coordinates geo_tiff. tif_bBox # the bounding box as WGS 84 geo_tiff. tif_shape # the bounding box in the as_crs CRS geo_tiff.
crs_code # the current crs code geo_tiff. Get information (properties) about the geotiff: # the original crs code geo_tiff. If the geotiff file has multiple bands, you can specify which band to use: geo_tiff = GeoTiff ( tiff_file, band = 1 ) Or you can use the original crs by setting as_crs to None: geo_tiff = GeoTiff ( tiff_file, as_crs = None ) If it's 'user defined' and you know what it should be, you may supply a crs code: geo_tiff = GeoTiff ( tiff_file, crs_code = 4326 )īy default, the coordinates will be in WGS 84, however they can be specified by using the as_crs param: geo_tiff = GeoTiff ( tiff_file, as_crs = 7844 ) Usage Making the GeoTiff object from geotiff import GeoTiff geo_tiff = GeoTiff ( tiff_file )
Installing this package is as easy as: pip install geotiff
NoGDAL is a philosophy for developing geospatial programs in python without using GDAL. Please support this project be giving it a star on GitHub! What is noGDAL? WARNING this package is under development and some features are unstable.