1 % make .mat files from a kml for use in data assimilation
2 % requires mapping toolbox and the kml2struct.m function
4 kmlFile = '../cycling_data/TIFs/doc.kml';
5 a = kml2struct(kmlFile);
6 %load('perim_struct.mat');
12 %%%%%%% start 13 for special point %%%%%%%%
13 % number of points in grid to use
17 if strcmp(a(i).Geometry,'Polygon')
18 p_count = p_count + 1;
21 %set decimate to an postive integer to use just a subset of points
24 lats = a(i).Lat(1:decimate:end);
25 lons = a(i).Lon(1:decimate:end);
27 %create regularly spaced data
28 dx = (a(i).BoundingBox(2,1)-a(i).BoundingBox(1,1))/n;
29 dy = (a(i).BoundingBox(1,2)-a(i).BoundingBox(2,2))/n;
31 xa = linspace(a(i).BoundingBox(1,1),a(i).BoundingBox(2,1),n);
32 ya = linspace(a(i).BoundingBox(2,2),a(i).BoundingBox(1,2),n);
34 %find data inside of perimeter
35 [x,y] = meshgrid(xa,ya);
38 [in,on] = inpolygon(x,y,lons,lats);
39 fires = logical(in+on);
40 data = reshape(fires,n,n);
41 %make all high confidence fires
42 data = uint8(9.0*data);
44 geotransform = [ a(i).BoundingBox(1,1) dx 0 a(i).BoundingBox(2,2) 0 dy];
45 a(i).geotransform = geotransform;
46 %save the file for use in data assimilation
47 %save(a(i).TIF_name,'data','geotransform');
55 scatter(x(fires),y(fires),'*','r');
65 %save perim_struct.mat a
66 fprintf('There were %i perimeters found in the data set\n',p_count)