Changeset 15160


Ignore:
Timestamp:
05/30/13 10:00:20 (12 years ago)
Author:
Mathieu Morlighem
Message:

CHG: rotate Google map image so that we usethe same projection (requires new gdal and proj.4...)

Location:
issm/trunk-jpl/src/m/plot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/plot/googlemaps.m

    r15155 r15160  
    4848end
    4949
     50%Get region specific projection parameters
     51EPSGgoogle = 'EPSG:3785';   % Mercator       http://www.spatialreference.org/ref/epsg/3785/
     52if strcmpi(md.mesh.hemisphere,'n'),
     53        EPSGlocal = 'EPSG:3413'; % UPS Greenland  http://www.spatialreference.org/ref/epsg/3413/
     54elseif strcmpi(md.mesh.hemisphere,'s'),
     55        EPSGlocal = 'EPSG:3031'; % UPS Antarctica http://www.spatialreference.org/ref/epsg/3031/
     56else
     57        error('field hemisphere should either be ''n'' or ''s''');
     58end
     59
    5060%Find optimal zoom
    5161if exist(options,'zoom'),
     
    8595                position = [num2str(latn) ',' num2str(lonn)];
    8696                disp(['Google Earth tile: ' num2str(x) '/' num2str(cols-1) ' ' num2str(y) '/' num2str(rows-1) ' (center: ' position ')']);
    87                 %Google maps API
    88                 %http://developers.google.com/maps/documentation/staticmaps/
     97                %Google maps API: http://developers.google.com/maps/documentation/staticmaps/
    8998                params = [...
    9099                        'center=' position ...
     
    105114end
    106115
    107 %Create coordinates grids
    108 [gX gY]=meshgrid(ulx:ulx+size(final,2)-1,uly:-1:uly-size(final,1)+1);
    109 [LAT LON]=pixelstolatlon(gX,gY, zoom);
    110 if strcmpi(md.mesh.hemisphere,'n'),
    111         [X Y]=ll2xy(LAT,LON,+1,45,70);
    112 elseif strcmpi(md.mesh.hemisphere,'s'),
    113         [X Y]=ll2xy(LAT,LON,-1,0,71);
    114 else
    115         error('field hemisphere should either be ''n'' or ''s''');
    116 end
     116%Write image, create geotiff and reproject from mercator to local projection
     117imwrite(final,'temp.png','png')
     118[ulmx ulmy]=ll2mercator(ullat,ullon);
     119[lrmx lrmy]=ll2mercator(lrlat,lrlon);
     120
     121%Create Geotiff for Mercator projection
     122system(['gdal_translate -of Gtiff -co "tfw=yes"  -a_ullr '...
     123        num2str(ulmx,'%15.8f') ' ' num2str(ulmy,'%15.8f') ' ' num2str(lrmx,'%15.8f') ' ' num2str(lrmy,'%15.8f')...
     124        ' -a_srs "' EPSGgoogle '" "temp.png" "temp.tiff"']);
     125delete('temp.png');
     126
     127%reproject from mercator (EPSG:3785) to UPS Ant (EPSG:3031)
     128system(['gdalwarp  -s_srs ' EPSGgoogle ' -t_srs ' EPSGlocal ' temp.tiff temp2.tiff']);
     129delete('temp.tiff','temp.tfw');
     130
     131%Put everything in model
     132[status output]=system('gdalinfo temp2.tiff | grep "Upper Left"');
     133ul = sscanf(output,'Upper Left  (%f, %f)');
     134[status output]=system('gdalinfo temp2.tiff | grep "Lower Right"');
     135lr = sscanf(output,'Lower Right (%f, %f)');
     136[status output]=system('gdalinfo temp2.tiff | grep "Size is"');
     137si = sscanf(output,'Size is %i, %i');
     138x_m=linspace(ul(1),lr(1),si(1));
     139y_m=linspace(ul(2),lr(2),si(2)); %We need to reverse y_m because the image is read upside down by matlab
     140final=imread('temp2.tiff');
     141delete('temp2.tiff');
    117142
    118143md.radaroverlay.pwr=final;
    119 md.radaroverlay.x=X;
    120 md.radaroverlay.y=Y;
     144md.radaroverlay.x=x_m;
     145md.radaroverlay.y=y_m;
    121146
    122147end
  • issm/trunk-jpl/src/m/plot/plot_googlemaps.m

    r15155 r15160  
    4747
    4848%Retrieve image from md
    49 X = md.radaroverlay.x;
    50 Y = md.radaroverlay.y;
    51 final = md.radaroverlay.pwr;
     49[X Y] = meshgrid(md.radaroverlay.x,md.radaroverlay.y);
     50final = double(md.radaroverlay.pwr)/double(max(md.radaroverlay.pwr(:))); %rescale between 0 and 1
    5251
    5352%Get some options
Note: See TracChangeset for help on using the changeset viewer.