1
votes

I have a set of data that needs to be organised into sections based on where the data was collected. There are 5 sections that the data may fall into, therefore I need to separate the data into these five sections based on their latitude and longitude. How would I go about doing this?

Here is a sample. The first few columns contain information regarding the voyage, the 5th column contains the latitude at which the data was collected, the 6th contains the longitude. The next columns contain information on time of collection and results of the data collection.

2 , NaN, 83, NaN, -62.18, -36.59, 1983, 318, 0, 0.1, NaN, 0.28, 6, 1.06, 0.66, 0.41, 0.29, 0.26, 0.30, 0.39, 0.49, 0.60, 0.67, 0.68, 0.64, 0.56, 0.45, 0.36, 0.28, 0.22, 0.18, 0.15, 0.13, 0.11, 0.10, 0.09, 0.07

1
Some example of data and the expected result would be useful.Marcin
it is difficult to show a sample of the data as it is a 890 by 37 matrix. The first few columns contain information regarding the voyage, the 5th column contains the latitude at which the data was collected, the 6th contains the longitude. The next columns contain information on time of collection and results of the data collection. A simplified example of one row would be: 2 , NaN, 83, NaN, -62.18, -36.59, 1983, 318, 0, 0.1, NaN, 0.28, 6, 1.06, 0.66, 0.41, 0.29, 0.26, 0.30, 0.39, 0.49, 0.60, 0.67, 0.68, 0.64, 0.56, 0.45, 0.36, 0.28, 0.22, 0.18, 0.15, 0.13, 0.11, 0.10, 0.09, 0.07 Thanks,user2877623
How are these Areas defined? Polygons? Min/Max longitude / latitude? Circles?Daniel

1 Answers

0
votes

You can use csvread as the data is numeric only. And access the lat/lon by standard column indexing.

M = csvread(filename);
lat = M(:,5);
lon = M(:,6);

Then select the indexes corresponding to your criteria and extract the data

% a N x 4 matrix, N lines for the number of groups, and 4 columns for min(lat) max(lat) min(lon) max(lon) 
lat_lon_values = [10 20 50 80;
    20 30 50 80;
    50 70 10 60];

for ind_group = 1:size(lat_lon_values, 1)

    a = lat_lon_values(ind_group, 1); %min(lat)
    b = lat_lon_values(ind_group, 2); %max(lat)
    c = lat_lon_values(ind_group, 3); %min(lon)
    d = lat_lon_values(ind_group, 4); %max(lon)

    %select the indexes based on lat and lon values
    ind_line = M(5,:)>= a & M(5,:)<= b & M(6,:)>= c & M(6,:)<= d;

    %your selected data
    M(ind_line, :)

end