Skip to content

Commit

Permalink
Merge pull request #410 from Gedeon-m-gedus/Fix_clipping_issue_area_e…
Browse files Browse the repository at this point in the history
…stimate_notebook

Fix set NODATA and raster re-projection when clipping
  • Loading branch information
Gedeon-m-gedus authored Aug 13, 2024
2 parents 36ab26b + 3a0d753 commit 9155e63
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/area_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,21 @@ def load_raster(
\n You need to project the map to the local UTM Zone \
(EPSG:XXXXX)."""
)

t_srs = input("Input EPSG Code; EPSG:XXXX:")
options = {"dstSRS": f"EPSG:{t_srs}", "dstNodata": 255}
gdal.Warp(f"prj_{in_raster_basename}", in_raster_basename, **options)
in_raster = f"prj_{in_raster_basename}"
return clip_raster(in_raster, boundary)
options = gdal.WarpOptions(dstSRS=f"EPSG:{t_srs}", dstNodata=255)
output_raster = f"prj_{in_raster_basename}"
gdal.Warp(output_raster, in_raster, options=options)
in_raster = output_raster

else:
print("Map CRS is %s. Loading map into memory." % src.crs)
return clip_raster(in_raster, boundary)
print("Map CRS is %s. Setting nodata value to 255." % src.crs)
options = gdal.WarpOptions(dstNodata=255)
output_raster = f"nodata_{in_raster_basename}"
gdal.Warp(output_raster, in_raster, options=options)
in_raster = output_raster

return clip_raster(in_raster, boundary)


def binarize(
Expand Down

0 comments on commit 9155e63

Please sign in to comment.