-
Notifications
You must be signed in to change notification settings - Fork 3
/
regionalize.m
87 lines (80 loc) · 2.79 KB
/
regionalize.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
function regionalize(regi)
% REGIONALIZE(regi)
%
% Constructs databases of geologic regions from the USGS.
% Later on these get projected and saved with other data.
%
% INPUT:
%
% regi 'WORLDGeol1' to do everything, i.e. the master set
% 'AFRGeol1' to do specifically Africa
% 'SAGeol1' to do specifically South America
% [Other regions to come which aren't from the USGS]
%
% Written by dongwang-at-princeton.edu, 04/16/2010
% Last modified by fjsimons-at-alum.mit.edu, 3/2/2011
%
% Previously known as: make_region_world_1, make_region_Africa_1,
% make_region_SouthAmerica_1.m, etc...
% Where are the data kept or stored?
worldir=fullfile(getenv('IFILES'),'GEOLOGY','WORLD');
% What is the Matlab version of this?
allfname=fullfile(worldir,'WORLDGeol1.mat');
% What is the specific region you want today?
fname=fullfile(worldir,sprintf('%s.mat',regi));
% If the regio doesn't exist you'll need to make it
if exist(fname,'file')~=2
% If the world doesn't exist you'll need to make that
if exist(allfname,'file')~=2
% Load the original shape file data
geoall=shaperead(fullfile(worldir,'WEP_PRVG'));
% Retrieve useful information - there is much more!
for ik=1:length(geoall)
WORLDGeol1(ik).X=geoall(ik).X;
WORLDGeol1(ik).Y=geoall(ik).Y;
WORLDGeol1(ik).GEOLPROV=geoall(ik).NAME;
WORLDGeol1(ik).AREA=geoall(ik).AREA;
end
% Data source
webaddress='https://certmapper.cr.usgs.gov/data/wep/dds60/wep_prvg.htm';
bigweb='http://certmapper.cr.usgs.gov';
docId='F75EF7E7-963B-413A-9539-BCA88D755B01';
src1=sprintf('[1] %s/data/we/dds60/spatial/shape/wep_prvg.zip',bigweb);
src2=sprintf('[2] %s/rooms/utilities/full_metadata.jsp?docId={%s}',bigweb,docId);
src3=sprintf('[3] http://pubs.usgs.gov/dds/dds-060/');
source=sprintf('%s \n%s \n%s ',src1,src2,src3);
% Commit to file
save(allfname,'WORLDGeol1','source')
else
load(allfname)
end
% Now you make and save the region
switch regi
case 'AFRGeol1'
regionrange=[65 -55 -40 80];
case 'SAGeol1'
regionrange=[40 -80 240 360];
% Change it to [0 360]
for ik=1:length(WORLDGeol1)
WORLDGeol1(ik).X(WORLDGeol1(ik).X<0)=...
WORLDGeol1(ik).X(WORLDGeol1(ik).X<0)+360;
end
end
% Now pick out what matters
jk=0;
for ik=1:length(WORLDGeol1)
tempindx=WORLDGeol1(ik).X>=regionrange(3) & ...
WORLDGeol1(ik).X<=regionrange(4);
tempindy=WORLDGeol1(ik).Y>=regionrange(2) & ...
WORLDGeol1(ik).Y<=regionrange(1);
tempind=tempindx & tempindy;
if ~isempty(find(tempind))
jk=jk+1;
eval(sprintf('%s(jk)=WORLDGeol1(ik);',regi));
eval(sprintf('%s(jk).X(~tempind)=NaN;',regi));
eval(sprintf('%s(jk).Y(~tempind)=NaN;',regi));
end
end
% SAVING
save(fname,regi,'source')
end