フィルターのクリア

How to find number of pixels and pixel ID based on Latitude and Longitude Information?

2 ビュー (過去 30 日間)
Dear MATLAB Research Community,
I have to find number of pixels and pixel IDs based on Latitude and Longitude Information given below.
Here is the link where I have uploaded the data for reference and code.
I have sorted the way to read the data which is for one day of scan and the way to read latitude and longitude information as well.
This file loop_read_1_day_data.m is containing code.
I have to find the pixel numbers and ID of that pixel from complete data for this range [Lat, long] = [ -72.345785°, 170.044070°] in decimal.
Then I have to find that ID in brightness image to find brightness temperature of that pixels.
  2 件のコメント
Pratyush Swain
Pratyush Swain 2024 年 4 月 18 日
Hi Amjad,
Correct me if I am wrong but this is what i have understood from your query. You have to find the set of indices in form (row,col) of the values from latitude and longitude information which are the closest to this range [Lat, long] = [ -72.345785°, 170.044070°] and use the same set of indexes to find the brightness values. Is this your requirement ?
Amjad Iqbal
Amjad Iqbal 2024 年 4 月 18 日
Yes, to find latitude and longitude pixels in this range at first
[col_lat row_lat] = find(lat>-72.3250 & lat<-72.2000);
Latitude = [col_lat row_lat];
[col_long row_long] = find(long>169.95 & long<170.05);
Longitude = [col_long row_long];
And then find matching rows in both Latitude and Longitude where (at which pixel indices) they have same value. That pixel will be then collected from Brightness to obtain information.

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

採用された回答

Pratyush Swain
Pratyush Swain 2024 年 4 月 18 日
Hi Amjad,
Please refer to this workflow which can help you in finding common rows and cols for pixel values satisfying the custom range conditions:
% Specifying latitude and longitude range as per your requirement %
lat_range = [-72.3250, -72.2000];
lt_range = [169.95, 170.05];
% Creating global arrays which will store the lat and long values
% satisfying range criteria and also the brightness values at their
% intersection points
all_lat_values = [];
all_long_values = [];
all_brightness_values = [];
% Iterate through all files
for i = 1:14
% Implementation for reading brightness image and lat & long
% ------------------------------------------------ %
% Implementation for resizing brightness img,lat and long matrix to
% common dimensions
% ------------------------------------------------ %
% Finding latitudes and longitudes rows & cols satisfying range
% criteria %
[row_lat, col_lat] = find(lati_resized > lat_range(1) & lati_resized < lat_range(2));
[row_long, col_long] = find(lt_resized > lt_range(1) & lt_resized < lt_range(2));
% Forming latitude and longitude indices array consisting of rows and
% cols values
lat_indices = [row_lat, col_lat];
long_indices = [row_long, col_long];
% Finding matching indices between lat and long indices array by using the intersect function %
% "Stable" parameter insures the matching indices come in ordered way %
[common_indices, ~] = intersect(lat_indices, long_indices, 'rows', 'stable');
% Segregating matched rows and matched columns %
matched_rows = common_indices(:, 1);
matched_cols = common_indices(:, 2);
% Forming linear indices using the sub2ind function %
linear_indices = sub2ind(size(B), matched_rows, matched_cols);
% These linear indices are applicable to all matrices since all were
% resized to common dimensions
lat_values = lati_resized(linear_indices);
long_values = lt_resized(linear_indices);
% Finally Using the indices to find brightness values %
matched_brightness_values = B(linear_indices);
% Append the values to the global arrays %
all_lat_values = [all_lat_values; lat_values];
all_long_values = [all_long_values; long_values];
all_brightness_values = [all_brightness_values; matched_brightness_values];
end
You can also visualize the findings using a scatter plot between latitude,longitude and brightness values:
figure;
scatter3(all_lat_values, all_long_values, all_brightness_values, 36, all_brightness_values, 'filled');
colorbar;
colormap(jet);
title('3D Plot of Brightness Temperatures vs. Latitude and Longitude');
xlabel('Longitude');
ylabel('Latitude');
zlabel('Brightness Temperature');
view(3);
Some of the functions I used above and their uses are as follow :
1- find() : Find all the indices satisfying a criteria in a matrix
2- intersect(): Finds data common to two arrays.
3- sub2ind(): Returns the linear indices corresponding to the row and column subscripts.
For more information on functions and their parameters, please refer to following resources:
I hope this example implementation helps you in your use case. I have also attached the code file for your reference. I also have tested it on the data you had provided.
  1 件のコメント
Amjad Iqbal
Amjad Iqbal 2024 年 4 月 18 日
Thank you so much for your great efforts. I was missing this intersection part, but it makes sense now.
One more query, How we can find these 6 pixels are coming from which dataset (out of 14)?
I need to plot the Brightness Vs DataSet for more coherent information.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by