cropping nc4 file with shapefile in matlab

1 view (last 30 days)
I want to crop my nc4 file according to my shapefile extent. I am trying this
file = 'GLDAS_NOAH10_3H.A20050102.0000.020.nc4' ;
lon = ncread(file,'lon') ;
lat = ncread(file,'lat') ;
RF = ncread(file,'SnowDepth_inst') ;
path = [pwd filesep 'indus_upper.shp'] ;
S = shaperead(path) ;
n = length(S) ;
%[Z, R] = vec2mtx(S.Y, S.X, 0.25, 'filled');
%for i = 1:length(myY)
% x = S(i).X ; y = S(i).Y ;
% plot(x,y,'k')
rfi = interp2(lon,lat,RF',myX,myY) ;
I am not sure about my making of meshgrid. Anybody tell me how can i resolve my problem?
  1 Comment
Muhammad Usman Saleem
Muhammad Usman Saleem on 25 Feb 2017
my shapefile and nc4 file attached with this post

Sign in to comment.

Answers (0)


Find more on Programming Utilities in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!