| Line | |
|---|
| 1 | function string = epsg2proj(epsg)
|
|---|
| 2 | %FUNCTION EPSG2PROJ - uses gdalsrsinfo to provide PROJ.4 compatible string from
|
|---|
| 3 | %EPSG code
|
|---|
| 4 | %
|
|---|
| 5 | % Usage:
|
|---|
| 6 | % proj4string = epsg2proj(4326);
|
|---|
| 7 | %
|
|---|
| 8 | % Example:
|
|---|
| 9 | % proj4string = epsg2proj(4326);
|
|---|
| 10 | % return proj4string='+proj=longlat +datum=wgs84 +no_defs'
|
|---|
| 11 | %
|
|---|
| 12 | % First, get GDAL version
|
|---|
| 13 | [s,r]=system(['gdalsrsinfo --version | awk ''{print $2}'' | cut -d ''.'' -f1']);
|
|---|
| 14 |
|
|---|
| 15 | if s~=0,
|
|---|
| 16 | error(r);
|
|---|
| 17 | end
|
|---|
| 18 |
|
|---|
| 19 | version_major=str2num(r);
|
|---|
| 20 |
|
|---|
| 21 | [s,r]=system(['gdalsrsinfo epsg:' num2str(epsg) ' | grep PROJ.4 | tr -d ''\n'' | sed ''s/PROJ.4 : //''']);
|
|---|
| 22 |
|
|---|
| 23 | if s~=0,
|
|---|
| 24 | error(r);
|
|---|
| 25 | end
|
|---|
| 26 |
|
|---|
| 27 | if version_major==1,
|
|---|
| 28 | r=r(2:end-2);
|
|---|
| 29 | end
|
|---|
| 30 |
|
|---|
| 31 | string=(r);
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.