How to set outside a country values to NaN, in a 3d array (lat x lon x time) ?

1 vue (au cours des 30 derniers jours)
BN
BN le 2 Nov 2019
Modifié(e) : BN le 4 Nov 2019
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

Réponses (1)

Lateef Adewale Kareem
Lateef Adewale Kareem le 2 Nov 2019
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 commentaire
BN
BN le 2 Nov 2019
Modifié(e) : BN le 4 Nov 2019
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?

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by