Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- close all
- clear all
- data = single(csvread('SEDAC_POP_2000-01-01_gs_3600x1800.CSV')); %read population data
- data(data == 99999)=0; %make sea uninhabited
- sin_vector = sin((1:1800)/1800*pi);
- A=sum(sin_vector*data);
- %%
- new_data=single(zeros(1800,3600));
- new_data2=single(zeros(1800,3600));
- tic
- for lat = 1:1800 %loop latitude
- disp(lat/10)
- latrad = pi*lat/1800-pi/2;
- Filter = single(zeros(1800,3600)); %create empty filter matrix
- for lat2 = 1:1800 %loop latitude
- lat2rad = pi*lat2/1800-pi/2;
- delta_lat = lat2rad - latrad;
- x=sin(delta_lat/2)^2;
- y= cos(latrad) * cos(lat2rad);
- q=sin(lat2rad+pi/2);
- for lon2 = 1:3600 %loop longitude
- lon2rad = pi*lon2/1800-pi;
- delta_lon = lon2rad - pi;
- R = 6371;% Earth's radius in km
- d = R * 2 * asin(sqrt(x + y * sin(delta_lon/2)^2));
- if d < 10000
- Filter(lat2,lon2)=q;
- end
- end
- end
- for lon = 1:3600
- if data(lat,lon) == 0
- new_data(lat,lon)=sum(sum(single(circshift(Filter,[0 lon])).*data));
- else
- new_data2(lat,lon)=sum(sum(single(circshift(Filter,[0 lon])).*data));
- end
- end
- toc
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement