How to extract data from nc file by using shape file in MATLAB
78 次查看(过去 30 天)
显示 更早的评论
How to extract data from nc file by using shape file in matlab. I am sending a sample .nc file of resolution 1*1 degree and shapefile of India.
3 个评论
回答(3 个)
KSSV
2016-5-4
编辑:KSSV
2016-5-4
clc; clear all ;
file = 'cpc_rfe_v2.0_sa_dly.bin.20020101.nc' ;
lon = ncread(file,'lon') ;
lat = ncread(file,'lat') ;
RF = ncread(file,'RF') ;
%
path = [pwd filesep 'India State wise with telangana' filesep 'india27-11.shp'] ;
S = shaperead(path) ;
n = length(S) ;
pcolor(lon,lat,RF') ; shading interp ;
hold on
for i = 1%:n
x = S(i).X ; y = S(i).Y ;
rfi = interp2(lon,lat,RF',x,y) ;
end
Your next question is: 'I want data along the polygon, not along the boundary'. It is a project work and you expect everything online?
1 个评论
Muhammad Usman Saleem
2017-2-25
@KSSV dear, will you tell me how can i get data along the complete polygon ?
Jitesh Dadich
2019-4-9
this really helped me....
Dear @KSSV, what if the time is also given in the nc file i.e. nc data are in 3D...then how will we extract the data from .nc file according to given shapefile....
3 个评论
ANKUR KUMAR
2019-5-9
编辑:ANKUR KUMAR
2019-5-9
Example you can refer to for your convenience
W=shaperead('us_states.shp');
[data_cropped]=maskregion(lon,lat,data,W);
contourf(lon,lat,nanmean(data_cropped,3)','linecolor','none')
5 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Map Display 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!