필터 지우기
필터 지우기

Finding whether set of coordinates are within a bounding box set by a condition

조회 수: 8 (최근 30일)
Elizabeth Case
Elizabeth Case 2020년 2월 19일
댓글: darova 2020년 2월 24일
Hi,
I have two meshgrids of X and Y coordinates (UTM/polar stereographic) with a corresponding grid of elevation values.
I have a set of specific coordinates marking sites of interest and I'd like to find out if they fall within a particular elevation band.
E.g.
index1 = elevation > 3000
and I want to find if any of the sites fall in the coordinates specified by the elevation. The specific points will not correspond exactly to the points on the meshgrid.
I've tried inpolygon, filterm, etc to no avail.
Update
Added sample data: etopo_15.mat loads LAT, LON and topo_bed (elevation) matrices.
You can plot this using
figure();
pcolor(LON,LAT,topo_bed)
shading flat
% And let's say the coordinates of the sites I'm interested in are
coords = [2.43875e+02,-48.375;2.45625e+02,44.87540.125,5.375;2.47125e+02,10.625]%[LON1,LAT1;LON2,LAT2...]
I create elevation bands from
elev1 = find(topo_bed > 3000);
elev2 = find(topo_bed > 1000 & topo_bed<2000);
How do I find out if the sites in coords are in those elevations?
I think one method might be to make a polygon from the elevation criteria, and the use inpolygon? Having trouble making a polygon from the matrix though..
  댓글 수: 4
Elizabeth Case
Elizabeth Case 2020년 2월 24일
편집: Elizabeth Case 2020년 2월 24일
Hi darova,
The image is really small, I can't see what you've painted, could you repost it? Thanks!

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

답변 (1개)

Guillaume
Guillaume 2020년 2월 20일
편집: Guillaume 2020년 2월 20일
Can't you just create an interpolant for your elevation and query the interpolant at your desired coordinates. It's then trivial to check if the elevation is in the desired bands:
%note that griddedInterpolant want NDGRID'ed data, not MESHGRID'ed data, so everything has to be transposed
ElevInterp = griddedInterpolant(LON.', LAT.', topo_bed.'); %using default linear interpolant here. Use whichever interpolation method you prefer
siteelevation = ElevInterp(coords) %get elevation at site coordinates
isinband = siteelevation > 3000 | (siteelevation > 1000 & siteelevation < 2000)
  댓글 수: 2
Elizabeth Case
Elizabeth Case 2020년 2월 24일
편집: Elizabeth Case 2020년 2월 24일
Hi Guillaume, this seems like a good option. I'm getting an error in gridded interopolant that might grids aren't monotonically increasing, but as far as I know/can tell, they are (see attached imshow). I'll try something along these lines and follow up here.
update: the issue is that my y (polar stereographic) values are decreasing
Guillaume
Guillaume 2020년 2월 24일
As long as the grid vectors are strictly monotonic, griddedInterpolant should work, it doesn't matter if it's monotonically increasing or decreasing. Certainly, I have no issue with the LAT and LON in your attached mat file.
If the coordinates are not monotonic or not gridded, you can always use scatteredInterpolant instead. The syntax is slightly different from that of griddedInterpolant but the principle is the same.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by