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

回答(1 个)

Lateef Adewale Kareem
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.
  1 个评论
BN
BN 2019-11-2
编辑:BN 2019-11-4
Thank you for your guidance. I share the polygon (containing bounding box and X and Y point of the country) with you. could you please tell me now how to use them for cutting my 3d array?

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by