How to set outside a country values to NaN, in a 3d array (lat x lon x time) ?
2 次查看(过去 30 天)
显示 更早的评论
Hi
I have a 3 dimension array which is precipitation = longitude*latitude*time. I extract this file from a netcdf file. altogh I was adjust latitude and longitude limit when I was reading netcdf latitude and longtude, but now I have an rectangular which some sides of it are offside of my stude region.
the study region is a one country.
I want to know how to ignore all latitude and longitude and corresponding time dimension values in order to have a clear figure (eliminate all other data outside the boundary of the country)
thank you for all your helps
0 个评论
回答(1 个)
Lateef Adewale Kareem
2019-11-2
The best solution is to use google map to get latitudes and logitudes of vertices of a polygon representing the external boundary of the country you are interested in. Make sure you collected the data in clockwise manner. Then test points against 2 contiguous pairs of point on the vertices, if you get a negative sign in any case, the point is outside and set it to nan.
By test I mean compute area using the determinant method.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NetCDF 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!