[Gdal-dev] Fixing projections with GDAL_TRANSLATE vs. GDALWARP
Matt Wilkie
matt.wilkie at gov.yk.ca
Wed Sep 12 15:58:51 EDT 2007
> If I fix the projection and convert to EPSG:4326 in 2 steps, using
> "gdal_translate" and then "gdalwarp" my image "geo2.tif" is not
> correctly geolocated.
>
> $ gdal_translate -a_srs "+proj=merc +lat_ts=41.65 +lon_0=-70.3166667
> +datum=nad83" mb_backpc30m.tif merc.tif
> $ gdalwarp -t_srs EPSG:4326 merc.tif geo2.tif
Are you using windows? On windows with gdal installed via fwtools 1.07
and later gdalwarp seems to omit reading the source projection, i.e. you
must use both -s_srs and -t_srs. When I do that with your source image,
the results are the same as 1-step-with-gdalwarp result (see attached).
This bug is filed as http://trac.osgeo.org/gdal/ticket/1471 - gdalwarp
should keep georeferencing info
Result of "1-step-warp" and "2-step-warp with -s_srs"
--- info-geo1.txt 2007-09-12 12:56:45.775811600 -0700
+++ info-geo3.txt 2007-09-12 12:56:46.541451300 -0700
@@ -1,5 +1,5 @@
Driver: GTiff/GeoTIFF
-Files: geo1.tif
+Files: geo3.tif
Size is 2780, 2299
Coordinate System is:
GEOGCS["WGS 84",
Result of "1-step-warp" and "2-step-warp with OUT -s_srs"
--- info-geo1.txt 2007-09-12 12:56:45.775811600 -0700
+++ info-geo2.txt 2007-09-12 12:56:46.650828400 -0700
@@ -1,5 +1,5 @@
Driver: GTiff/GeoTIFF
-Files: geo1.tif
+Files: geo2.tif
Size is 2780, 2299
Coordinate System is:
GEOGCS["WGS 84",
@@ -10,8 +10,8 @@
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]
-Origin = (-70.900180070696592,42.800132605138998)
-Pixel Size = (0.000311788157942,-0.000311788157942)
+Origin = (-70.900180070700841,42.800132604450049)
+Pixel Size = (0.000311788157943,-0.000311788157943)
Metadata:
AREA_OR_POINT=Area
Corner Coordinates:
--
matt wilkie
--------------------------------------------
Geographic Information,
Information Management and Technology,
Yukon Department of Environment
10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
867-667-8133 Tel * 867-393-7003 Fax
http://environmentyukon.gov.yk.ca/geomatics/
--------------------------------------------
-------------- next part --------------
@echo off
:: 1-step-gdalwarp
:: result has correct geo-referincing
gdalwarp -s_srs "+proj=merc +lat_ts=41.65 +lon_0=-70.3166667 +datum=nad83" -t_srs EPSG:4326 mb_backpc30m.tif geo1.tif
:: 2-step gdal_translate + gdalwarp
gdal_translate -a_srs "+proj=merc +lat_ts=41.65 +lon_0=-70.3166667 +datum=nad83" mb_backpc30m.tif merc.tif
gdalwarp -t_srs EPSG:4326 merc.tif geo2.tif
:: 2-step with warp, specifying source proj info
gdalwarp -t_srs EPSG:4326 -s_srs "+proj=merc +lat_ts=41.65 +lon_0=-70.3166667 +datum=nad83" merc.tif geo3.tif
::compare results
gdalinfo geo1.tif > info-geo1.txt
gdalinfo geo2.tif > info-geo2.txt
gdalinfo geo3.tif > info-geo3.txt
echo.
echo. Result of "1-step-warp" and "2-step-warp with -s_srs"
echo.
diff -u info-geo1.txt info-geo3.txt
echo.
echo. Result of "1-step-warp" and "2-step-warp with OUT -s_srs"
echo.
diff -u info-geo1.txt info-geo2.txt
More information about the Gdal-dev
mailing list