Converting Geospatial data into Arrays
Show older comments
How can I convert spatial information like land use(source:corine land cover map) to a 2D array of numbers, like a 2D spatial array based on latitude/longitude, with input parameters to specify the minimum and maximum desired latitude and longitude, as well as the desired spacing between the points in the 2D array? For example how can i convert the image(land use) into a matrix/array and get information for each point.
%% Reading The Data
Z = shaperead('LanduseMVA');
T = readtable('Z:\MarVitAIXpr\CLC_legend.csv');
index = [];
im_R = int8(zeros(15000,15000));
im_G = int8(zeros(15000,15000));
im_B = int8(zeros(15000,15000));
for tt2 = 1:size(T,1)
indcol{tt2} = num2str(table2array(T(tt2,2)));
end
for tt=1:size(Z,1)
disp([num2str(tt) ' di ' num2str(size(Z,1))])
ind1 = ~isnan(Z(tt).X) & ~isnan(Z(tt).Y);
ind2 = strcmp(Z(tt).code_12,indcol);
cctemp = (cell2mat(table2array(T(ind2,4))));
cc(1,1) = str2num(cctemp(1:3))/255;
cc(1,2) = str2num(cctemp(5:7))/255;
cc(1,3) = str2num(cctemp(9:11))/255;
fill(Z(tt).X(ind1),Z(tt).Y(ind1),cc)
if Z(tt).X(1)>3855000 && Z(tt).X(1)<4150000 && Z(tt).Y(1)<2350000 && Z(tt).Y(end-1)<2350000
plot(Z(tt).X,Z(tt).Y,'.k')
hold all
index = [index tt];
end
ascis = (Z(tt).X(ind1)-3855000)/10;
ordin = (Z(tt).Y(ind1)-2200000)/10;
bw = poly2mask(ascis,ordin,15000,15000);
im_R = im_R+int8(bw.*cc(1));
im_G = im_G+int8(bw.*cc(2));
im_B = im_B+int8(bw.*cc(3));
end
im(:,:,1) = flipud(([im_R]));
im(:,:,2) = flipud(([im_G]));
im(:,:,3) = flipud(([im_B]));
image(im)
axis equal
imagesc(im(:,:,1))

Answers (0)
Categories
Find more on Standard File Formats in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!