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

조회 수: 2 (최근 30일)
BN
BN 2019년 11월 2일
편집: BN 2019년 11월 4일
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
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.
  댓글 수: 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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by