@@ -162,6 +162,7 @@ def from_array(
162162 nodata : int | float | None = None ,
163163 area_or_point : Literal ["Area" , "Point" ] | None = None ,
164164 tags : dict [str , Any ] = None ,
165+ cast_nodata : bool = True ,
165166 vcrs : Literal ["Ellipsoid" ]
166167 | Literal ["EGM08" ]
167168 | Literal ["EGM96" ]
@@ -180,13 +181,21 @@ def from_array(
180181 :param nodata: Nodata value.
181182 :param area_or_point: Pixel interpretation of the raster, will be stored in AREA_OR_POINT metadata.
182183 :param tags: Metadata stored in a dictionary.
184+ :param cast_nodata: Automatically cast nodata value to the default nodata for the new array type if not
185+ compatible. If False, will raise an error when incompatible.
183186 :param vcrs: Vertical coordinate reference system.
184187
185188 :returns: DEM created from the provided array and georeferencing.
186189 """
187190 # We first apply the from_array of the parent class
188191 rast = SatelliteImage .from_array (
189- data = data , transform = transform , crs = crs , nodata = nodata , area_or_point = area_or_point , tags = tags
192+ data = data ,
193+ transform = transform ,
194+ crs = crs ,
195+ nodata = nodata ,
196+ area_or_point = area_or_point ,
197+ tags = tags ,
198+ cast_nodata = cast_nodata ,
190199 )
191200 # Then add the vcrs to the class call (that builds on top of the parent class)
192201 return cls (filename_or_dataset = rast , vcrs = vcrs )
@@ -300,7 +309,7 @@ def to_vcrs(
300309 zz_trans = _transform_zz (crs_from = src_ccrs , crs_to = dst_ccrs , xx = xx , yy = yy , zz = zz )
301310
302311 # Update DEM
303- self ._data = zz_trans .astype (self .dtypes [ 0 ] ) # type: ignore
312+ self ._data = zz_trans .astype (self .dtype ) # type: ignore
304313
305314 # Update vcrs (which will update ccrs if called)
306315 self .set_vcrs (new_vcrs = vcrs )
0 commit comments