Skip to content

Commit

Permalink
Merge pull request #1 from richardburcher/richardburcher-patch-write-…
Browse files Browse the repository at this point in the history
…tile-geotransform

Update GeoTile.py
  • Loading branch information
peanutbutter-memory authored Sep 15, 2023
2 parents 6f86770 + bce2b42 commit 0858f06
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions geotile/GeoTile.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,25 @@ def generate_tiles(

tile_path = os.path.join(output_folder, tile_name)

# tile georeference data to reconstruct spatial location from output inference bboxes
geo_reference_tile_worldfile = (f'{prefix}{str(i)}{suffix}.txt' if suffix or prefix else
f'tile_{col_off}_{row_off}.txt')

geo_reference_tile_worldfile_path = os.path.join(output_folder, geo_reference_tile_worldfile)

crs = meta["crs"]
crs = crs.to_proj4()

# save the tiles with new metadata
with rio.open(tile_path, 'w', **meta) as outds:
outds.write(self.ds.read(
out_bands, window=window, fill_value=nodata, boundless=True).astype(dtype))

# raster affine transform information
with open(geo_reference_tile_worldfile_path, "w") as f:
f.write(str(transform.to_gdal()))
f.write("\n")
f.write(crs)

if not save_tiles:
# convert list to numpy array
Expand Down

0 comments on commit 0858f06

Please sign in to comment.