How to replace NaN values with 0 of a GRIDobject?
Ältere Kommentare anzeigen
Hello
I have a raster and I imported it on Matlab as GRIDobject but it contains NaN and some values.
I want to change those NaN values with 0; and maybe if it is possible to create a logical GRIDobject
I have tried A(isnan(A))=0; command but is showing error because it isn't a matrix but a GRIDobject.
can anyone help me out this?
Thanks
3 Kommentare
Jonas
am 7 Jul. 2023
where did you find those GRIDobjects? a quick googling did not yield a suitable result
rossana napolitano
am 9 Jul. 2023
Wolfgang Schwanghart
am 5 Sep. 2023
Dear Rossana,
it might be better to ask TopoToolbox-related questions here: https://github.com/wschwanghart/topotoolbox/discussions
Best regards, Wolfgang
Antworten (1)
Cris LaPierre
am 9 Jul. 2023
Bearbeitet: Cris LaPierre
am 9 Jul. 2023
A quick look at the list of toolbox functions leads me to suggest looking into the isnan or inpaintnans functions that come with the toolbox. Both accept a GRIDobj as input.
function I = isnan(DEM)
% returns array elements that are NaNs as logical grid
%
% Syntax
%
% I = isnan(DEM)
%
% Description
%
% overloaded isnan for GRIDobj.
.
function DEM = inpaintnans(DEM,varargin)
%INPAINTNANS Interpolate or fill missing values in a grid (GRIDobj)
%
% Syntax
%
% DEMf = inpaintnans(DEM,type)
% DEMf = inpaintnans(DEM,type,k)
% DEMf = inpaintnans(DEM,type,k,conn)
% DEMf = inpaintnans(DEM,DEM2)
% DEMf = inpaintnans(DEM,DEM2,method)
% DEMf = inpaintnans(DEM,DEM2,'tt','fit',1,'eps',20)
%
% Description
%
% inpaintnans fills gaps in a grid (GRIDobj) generated by measurement
% errors or missing values. The user may choose between different
% techniques to fill the gaps. Note that the algorithm fills only
% pixels not connected to the DEM grid boundaries.
1 Kommentar
rossana napolitano
am 10 Jul. 2023
Kategorien
Mehr zu NaNs finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!