필터 지우기
필터 지우기

How to handle multiple text files (geographical info) and finding a particular location from each text file?

조회 수: 2 (최근 30일)
Hello matlab community,
I have multiple text files. Which contains time,value,lat,lon information. Each text file has a different dimension.
What I want is to extract all the information ( i.e. time,value) in a sorted manner for a particular (lon,lat) location occuring at all the text files which are of different dimension.
For example: I want to find all the values in sorted time format for a lon=100, lat=35, from all the text files.
I can share few text file if requires.
Thanking you in advance.

채택된 답변

Image Analyst
Image Analyst 2021년 9월 6일
2 hours with no answer. Yeah, I guess you need to attach the text files before anyone tries to deal with this problem. We don't know what arrays you have, like arrays for lat, long, time, value, etc. So all I can suggest at this point is to use the sort() function. In the meantime try something like
latLon = [lat(:), longitude(:)]; % Get all lats and lons in an N-by-2 array.
% There may be repeats, so extract only the unique locations.
uniqueLocations = unique(latLon, 'rows');
for row = 1 : size(uniqueLocations, 1)
thisLat = uniqueLocations(row, 1);
thisLon = uniqueLocations(row, 2);
% Find rows with that location
theseRows = lat == thisLat & longitude == thisLon;
% Extract times and values
theseTimes = time(theseRows);
theseValues = values(theseRows);
% Now do something with them.
end
  댓글 수: 2
Subhodh Sharma
Subhodh Sharma 2021년 9월 7일
편집: Subhodh Sharma 2021년 9월 7일
Thanks for you reply @Image Analyst. But there are thousands of text file. The latitude and longitude is not changing in any order. I don't know whether it would be good to extract all lon and lat at one position.
I have just attached 3 text files for your reference. You can readily see how the location is changing randomly. I don't know how extract all the information ( i.e. time,value) in a sorted manner for a particular (lon,lat) location occuring at all the text files which are of different dimension.
You can choose lon=-101.54 and lat=42.51
Thanking you in advance.
Image Analyst
Image Analyst 2021년 9월 7일
OK, but did you actually try to adapt my code? If so, did it work? Before I try I'd like to know. Also include your code.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by