How to get the pixel vales along a line?

조회 수: 10 (최근 30일)
Sophia
Sophia 2017년 10월 27일
댓글: Sophia 2017년 10월 30일
Let's say i want the pixel values along a line that connects two points
lat11 = 72;
lat21 = 81;
long12 = -150;
long22 = -180;
If i do the following i get the pixels for the entire area instead, How to get the pixels just along the line
[i1,j1] = find((lat1>=lat11 & lat1<=lat21) &(long1 >=long22 & long1<=long12));

답변 (2개)

Walter Roberson
Walter Roberson 2017년 10월 27일
If you were using an image, then improfile() would be appropriate.
However, you appear to be using a map.
If your georeference just happens to be rectangular linear, then you can use improfile() by matching lat and long to array indices.
However, your latitudes are much too high for you to be able to meaningfully use a rectangular linear georeference: there is very significant compression of the lines that far north.
At this point you need to start asking yourself which "line" you are talking about: Great Cicle? Small Circle? Geodesic taking into account the oblateness of the Earth? You appear to be looking up in the Beaufort Sea or the Arctic Ocean, where there might possibly have been significant scraping or depression due to glaciers, so you might need a more detailed shape model. There might perhaps be a Mapping Toolbox tool that is usable for this purpose; I am not familiar enough with that toolbox to say.
  댓글 수: 2
Sophia
Sophia 2017년 10월 27일
Thanks Walter, i have been using m_map and i did check the great circle script. But honestly just a simple transect would work for me for a simple line plot that shows how the values over that transect has been changing over the years.
Walter Roberson
Walter Roberson 2017년 10월 27일
m_map appears to be a third-party package https://www.eoas.ubc.ca/~rich/map.html . I am not familiar with that package.

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


Jan
Jan 2017년 10월 27일
It depends on what "the pixels" are. You can get n points on the line from [lat11, long12] to [lat21, long22] (by the way: strange names!):
n = 100;
latPos = linspace(lat11, lat21, n);
longPos = linspace(long21, long22, n);
In your question the variables "lat1" and long1" appear, but you did not explain any details. Perhaps they are matrices and you want to get the pixels nearest to the line? Or all pixels, which are touched by this line? This must be clarified at first.
  댓글 수: 2
Sophia
Sophia 2017년 10월 27일
hahaha..I realized the names were weird, i was typing and those were the first ones(weirdos) that came to my mind.. well, i got the curved line using the code that you mentioned.
lat1 and long1 are the original latitudes and longitudes from the dataset.and i1 and j1 are the associated pixels in which the data is stored.so basically once i have the lat and longs along that line i need to find in which i&j they are located.
My idea is to make a transect and see how the values over this transect has been changing over time. so i need the i and j which are the pixels that i will be looking into to plot for each year.
Sophia
Sophia 2017년 10월 30일
n = 100;
latPos = linspace(lat11, lat21, n);
longPos = linspace(long21, long22, n);
gives me the random lats and long Positions between those values but the trick is how to find the index associated with such values.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by