Reputation: 1
I have a map file in a tiff format that is not geo-referenced, but I know the following projection information: +proj=lcc +lon_0=10.856 +lat_0=51.322 +lat_1=42 +lat_2=57 +datum=WGS84. I would like to transform it into EPSG:3857.
In my first attempt I tried to fix four arbitrary points and perform warping
gdal_translate -a_srs "+proj=lcc +lon_0=10.856 +lat_0=51.322 +lat_1=42 +lat_2=57 +datum=WGS84" -of GTiff -gcp 19725 11865 1 56 -gcp 103755 12990 23 56 -gcp 112755 80400 23 46 -gcp 8925 78990 1 46 original.tif translated.tifBut the coordinates of the corners of the warped image where not as expected and the map was distorted.
Corner Coordinates: Upper Left ( 1208480.629, 6678543.890) ( 10d51'21.48"E, 51d19'21.08"N) Lower Left ( 1208480.629, 6678541.123) ( 10d51'21.48"E, 51d19'21.03"N) Upper Right ( 1208486.180, 6678543.890) ( 10d51'21.66"E, 51d19'21.08"N) Lower Right ( 1208486.180, 6678541.123) ( 10d51'21.66"E, 51d19'21.03"N) Center ( 1208483.404, 6678542.507) ( 10d51'21.57"E, 51d19'21.06"N)After reading many posts, here and elsewhere, I came to this:
Converting the UL and LR corners to x and y
cs2cs +proj=latlong +lon_0=10.856 +lat_0=51.322 +lat_1=42 +lat_2=57 +datum=WGS84 +to +init=epsg:3857 -3.63 57.28 > -404089.75 7817564.89 23.76 44.39 > 2644951.10 5525995.28
gdal_translate -a_srs "+proj=lcc +lon_0=10.856 +lat_0=51.322 +lat_1=42 +lat_2=57 +datum=WGS84" -a_ullr -404089.75 7817564.89 2644951.10 5525995.28 original.tif translated.tifThe result of gdalinfo translated.tif is as follows:
Size is 14735, 11333 Coordinate System is: PROJCS["unnamed", GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0], UNIT["degree",0.0174532925199433], AUTHORITY["EPSG","4326"]], PROJECTION["Lambert_Conformal_Conic_2SP"], PARAMETER["standard_parallel_1",42], PARAMETER["standard_parallel_2",57], PARAMETER["latitude_of_origin",51.322], PARAMETER["central_meridian",10.856], PARAMETER["false_easting",0], PARAMETER["false_northing",0], UNIT["metre",1, AUTHORITY["EPSG","9001"]]] Origin = (-404089.750000000000000,7817564.889999999664724) Pixel Size = (206.925066168985410,-202.203265684284787) Metadata: AREA_OR_POINT=Area TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch) TIFFTAG_XRESOLUTION=144 TIFFTAG_YRESOLUTION=144 Image Structure Metadata: INTERLEAVE=PIXEL Corner Coordinates: Upper Left ( -404089.750, 7817564.890) (146d18'53.31"E, 73d27'53.56"N) Lower Left ( -404089.750, 5525995.280) (158d45'33.92"W, 88d 1'24.64"N) Upper Right ( 2644951.100, 7817564.890) (172d26'19.88"W, 64d26'59.68"N) Lower Right ( 2644951.100, 5525995.280) (138d13'57.20"E, 73d22'12.76"N) Center ( 1120430.675, 6671780.085) (161d52'17.63"W, 79d37'35.75"N)However, the coordinates of the corners above are completely off. When I attempted to warp it, the image could become so huge that I had to stop the process after a couple of minutes.
gdalwarp -overwrite -t_srs EPSG:3857 -r near -co COMPRESS=LZW translated.tif warped.tifThe result of gdalinfo warped.tif is as follows:
Corner Coordinates: Upper Left (-20037508.339,29704755.766) (180d 0' 0.00"W, 88d54'44.28"N) Lower Left (-20037508.339, 9464937.842) (180d 0' 0.00"W, 64d26'59.58"N) Upper Right (20037503.600,29704755.766) (179d59'59.85"E, 88d54'44.28"N) Lower Right (20037503.600, 9464937.842) (179d59'59.85"E, 64d26'59.58"N) Center ( -2.370,19584846.804) ( 0d 0' 0.08"W, 84d41'15.52"N)
What did I miss?
Let's simplify the problem: how do I geo-reference the image file without converting the projection into EPSG:3857?
The first step I took was to embed the projection info and the four corner points:
gdal_translate -a_srs "+proj=lcc +lon_0=10.856 +lat_0=51.322 +lat_1=42 +lat_2=57 +datum=WGS84" -of GTiff -gcp 0 0 -4.226944 57.35083 -gcp 14735 0 27.78 57.59555 -gcp 14735 11333 24.30917 44.06611 -gcp 0 11333 -3.537778 43.6 original.tif georeferenced.tif
In the second step I warped georeferenced.tif without specifying a target projection:
gdalwarp -overwrite -r near georeferenced.tif warped.tif
When I checked warped.tif info got the following corner coordinates:
Corner Coordinates:
Upper Left ( -4.5777770, 57.6508975) ( 10d51'21.36"E, 51d19'21.08"N)
Lower Left ( -4.5777770, 43.6558450) ( 10d51'21.36"E, 51d19'20.62"N)
Upper Right ( 26.7396454, 57.6508975) ( 10d51'22.99"E, 51d19'21.08"N)
Lower Right ( 26.7396454, 43.6558450) ( 10d51'22.99"E, 51d19'20.62"N)
I was hoping to get:
Corner Coordinates:
Upper Left (0.0, 0.0) (-4.226944, 57.35083,0)
Lower Left (0.0, 11333.0) (-3.537778, 43.6,0)
Upper Right (14735.0, 0.0) (27.78, 57.59555,0)
Lower Right (14735.0, 11333.0) (24.30917, 44.06611,0)
Upvotes: 0
Views: 1040
Reputation: 64463
Are you sure you GCP's are correct? They should be in the form:
-gcp pixel line easting northing [elevation]]*
You have one GCP which suggest that your input file is at least 112755 x 80400 pixels (w x h) in size. Its possible of course, but its a large file.
I think you should combine your first attempt with your later gdalwarp
step. Since gdalwarp
doesn't take gcp's, and gdal_translate
can't warp, it takes two steps.
You can output your first step to a VRT
file, so it takes less processing and disk space.
gdal_translate -of VRT -a_srs "+proj=lcc +lon_0=10.856 +lat_0=51.322 +lat_1=42 +lat_2=57 +datum=WGS84" -gcp 19725 11865 1 56 -gcp 103755 12990 23 56 -gcp 112755 80400 23 46 -gcp 8925 78990 1 46 original.tif georeferenced.vrt
And then warp the VRT:
gdalwarp -overwrite -t_srs EPSG:3857 -r near -co COMPRESS=LZW georeferenced.vrt warped.tif
Upvotes: 0