Changeset 24879


Ignore:
Timestamp:
05/20/20 18:12:57 (5 years ago)
Author:
Eric.Larour
Message:

CHG: implemented read_contours.m routine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/contrib/larour/glacier_inventory.m

    r24878 r24879  
    7676        end
    7777        %}}}
     78                function readcontours(self) % {{{
     79                        %we are reading the contours from each shape file for each region, reproject
     80                        %the latlong in these contours to the local laea projection, and rewrite the shapefile
     81                        %we a different name extension.
     82
     83                        for i=1:self.nregions,
     84                               
     85                                disp(['reading shapefile for region: '  self.regions(i).name]);
     86                                contours=shaperead([self.root '/' self.regions(i).name '.shp']);
     87
     88                                disp(['concatenating contours (X,Y)']);
     89                                count=0;
     90                                for j=1:length(contours),
     91                                        count=count+length(contours(j).X);
     92                                end
     93                                xc=zeros(count,1);
     94                                yc=zeros(count,1);
     95                                count=0;
     96                                for j=1:length(contours),
     97                                        nj=length(contours(j).X);
     98                                        xc((count+j):(count+j+nj-1))=contours(j).X;
     99                                        yc((count+j):(count+j+nj-1))=contours(j).Y;
     100                                        count=count+nj;
     101                                end
     102
     103                                disp(['projecting (X,Y)']);
     104                                lat0= fix(mean(self.regions(i).CenLat)); long0=fix(mean(self.regions(i).CenLon));
     105                                proj=laea(lat0,long0); self.regions(i).proj=proj;
     106                                [xc,yc]=gdaltransform(xc,yc,'EPSG:4326',proj);
     107
     108                                disp(['plugging back into contours']);
     109                                count=0;
     110                                for j=1:length(contours),
     111                                        nj=length(contours(j).X);
     112                                        contours(j).X=xc((count+j):(count+j+nj-1));
     113                                        contours(j).Y=yc((count+j):(count+j+nj-1));
     114                                        count=count+nj;
     115                                end
     116                                disp(['saving new contours to disk']);
     117                                shapewrite(contours,[self.root '/' self.regions(i).name '.laeaproj.shp']);
     118                        end
     119                end
     120                %}}}
    78121                function disp(self) % {{{
    79122                        disp(sprintf('   Glacier inventory:'));
Note: See TracChangeset for help on using the changeset viewer.