フィルターのクリア

Using if and of two columns to find the value in another column

3 ビュー (過去 30 日間)
Joe Sheckles
Joe Sheckles 2020 年 2 月 22 日
コメント済み: Joe Sheckles 2020 年 2 月 24 日
I have a shape file. I cannot attach it since it is too large.
But I used the code to read as:
S = shaperead('conus_20160101_24h.grb-var0.shp')
Now, I am able to get my table.
There are five columns: "Fields", "Geometry", "X", "Y", "value", "datetime"
What I need is to find "value" based on "X" and "Y"
For instance, if X is between 78 and 79 and Y is between, 48 and 49, read the value in "Value".
Thanks,
J

採用された回答

Matt J
Matt J 2020 年 2 月 22 日
Here, I use T as the name of your table,
lookup=abs(T.X-78.5)<=0.5 & abs(T.Y-48.5)<=0.5;
T.Value(lookup),
  7 件のコメント
Matt J
Matt J 2020 年 2 月 24 日
編集済み: Matt J 2020 年 2 月 24 日
So, one solution would be to convert R1 to a table, and then use the steps I originally proposed, e.g.,
S=struct2table(R1);
S.X=-S.X; %for some reason all X were negative
lookup=abs(S.X-73.9668)<=1 & abs(S.Y-40.7995)<=1;
values = S.value(lookup);
Joe Sheckles
Joe Sheckles 2020 年 2 月 24 日
Yes. This works perfectly. Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by