extract matrix value based on lat lon data

조회 수: 3 (최근 30일)
Angela Bowman
Angela Bowman 2015년 11월 10일
댓글: Belinda Finlay 2020년 2월 21일
I have three matrices: 1) [m n] latitude 2) [m n] longitude 3) [m n] simulated values
I need to extract the simulated values by a given bounding box of latitude and longitude and create a new matrix [a b] for several time steps.
I have tried find, ind2sub, sub2ind, intersect, though none of those functions are quite what I need.
Please help!

채택된 답변

Chad Greene
Chad Greene 2015년 11월 10일
I think you want inpolygon. To get the indices of all data inside the polygon 30 to 40 degrees north and 20 to 10 degrees west, you'd do
ind = inpolygon(lon,lat,[-20 -10],[30 40]);
Then your data measurements in that polygon are: vals(ind)
There's a Mapping Toolbox function called ingeoquad that does the same thing, but inpolygon does it just as well and doesn't require the Mapping Toolbox.
  댓글 수: 2
Angela Bowman
Angela Bowman 2015년 11월 10일
Thank you! This works perfectly for my needs.
Belinda Finlay
Belinda Finlay 2020년 2월 21일
Is there something similar for a circle, where I can values from a specific grid point, and all data within radius of 500km?

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by