source:
issm/trunk-jpl/src/m/coordsystems/epsg2proj.m@
25189
Last change on this file since 25189 was 25189, checked in by , 5 years ago | |
---|---|
File size: 666 bytes |
Rev | Line | |
---|---|---|
[24777] | 1 | function string = epsg2proj(epsg) |
[25035] | 2 | %FUNCTION EPSG2PROJ - uses gdalsrsinfo to provide PROJ.4 compatible string from |
3 | %EPSG code | |
[24777] | 4 | % |
5 | % Usage: | |
6 | % proj4string = epsg2proj(4326); | |
7 | % | |
[25035] | 8 | % Example: |
9 | % proj4string = epsg2proj(4326); | |
10 | % return proj4string='+proj=longlat +datum=wgs84 +no_defs' | |
[24777] | 11 | % |
[25050] | 12 | % First, get GDAL version |
[25064] | 13 | [s,r]=system(['gdalsrsinfo --version | awk ''{print $2}'' | cut -d ''.'' -f1']); |
[24777] | 14 | |
[25050] | 15 | if s~=0, |
16 | error(r); | |
17 | end | |
[24777] | 18 | |
[25064] | 19 | version_major=str2num(r); |
[25050] | 20 | |
[25189] | 21 | [s,r]=system(['gdalsrsinfo epsg:' num2str(epsg) ' | command grep PROJ.4 | tr -d ''\n'' | sed ''s/PROJ.4 : //''']); |
[25050] | 22 | |
[24777] | 23 | if s~=0, |
24 | error(r); | |
25 | end | |
[25050] | 26 | |
27 | if version_major==1, | |
[25051] | 28 | r=r(2:end-2); |
[25050] | 29 | end |
30 | ||
[24957] | 31 | string=(r); |
Note:
See TracBrowser
for help on using the repository browser.