[Mapserver-west] georeferencing with GDAL
Ken-ichi Ueda
kenichi.ueda at gmail.com
Tue Jun 28 17:54:34 EDT 2005
Sorry for the delayed reply. gdal_translate adds GCPs to a raw file
nicely, but gdalwarp then complains about not having a source
coordinate system. Shouldn't it be able to warp a raw image without a
coordinate system? Here's what I did:
gdal_translate -gcp 261.108 404.217 -122 38 -gcp 1641.545 4069.735
-121.91667 38 -gcp 258.546 2160.779 -122 37.91667 -gcp 1643.564
2160.223 -121.91667 37.91667 -of GTiff input.img output.tif
gdalwarp -t_src '+proj=longlat +ellps=clrk66 +datum=NAD27' output.tif
output_geo.tif
which yields
A target coordinate system was specified, but there is no source coordinate
system. Consider using -s_srs option to provide a source coordinate system.
Operation terminated.
gdalinfo on output.tif looks like this:
Driver: GTiff/GeoTIFF
Size is 2289, 3002
Coordinate System is `'
GCP Projection =
GCP[ 0]: Id=1, Info=
(261.108,404.217) -> (-122,38,0)
GCP[ 1]: Id=2, Info=
(1641.55,4069.74) -> (-121.917,38,0)
GCP[ 2]: Id=3, Info=
(258.546,2160.78) -> (-122,37.9167,0)
GCP[ 3]: Id=4, Info=
(1643.56,2160.22) -> (-121.917,37.9167,0)
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 3002.0)
Upper Right ( 2289.0, 0.0)
Lower Right ( 2289.0, 3002.0)
Center ( 1144.5, 1501.0)
Band 1 Block=2289x3 Type=Byte, ColorInterp=Red
Band 2 Block=2289x3 Type=Byte, ColorInterp=Green
Band 3 Block=2289x3 Type=Byte, ColorInterp=Blue
Any suggestions?
-Ken-ichi
On 6/22/05, Tyler Mitchell <tylermitchell at shaw.ca> wrote:
> On June 22, 2005 12:27 pm, Ken-ichi wrote:
> > Hi all. First, it was great meeting many of you at OSG '05. Always
> > good to put faces to names.
>
> Likewise! Thanks for introducing yourself.
>
> > Second, forgive me if this is OT, but how do you georeference with GDAL?
>
> For the record, nothing is off-topic, so go for it!
>
> > According to the docs, gdalwarp can take a raw file with GCP "control
> > information" as input, but how do you save the control info to the file?
> > Is there a way to do it with an external file of GCPs? Or is there a
> > way to save GCPs to the file within Erdas IMAGINE? I basically have a
> > whole mess of raw tiffs with GCPs that I need to georeference, and it
> > would make my life a lot easier if I could just automate it with GDAL.
>
> It's not obvious, but you can use gdal_translate to add GCP's to an image, by
> using the -gcp option. Here's the option syntax:
> -gcp pixel line easting northing
> For multiple points (e.g. one for each corner) you just add another -gcp
> option with the values. So, you might do something like:
>
> gdal_translate -gcp 0 0 -180 90 -gcp 0 300 -180 -90 -gcp 600 0 180 -90 -gcp
> 600 300 180 90 input.tif output.tif
>
> Then run it through gdalwarp to transform the image. Hope that helps!
>
> Tyler
>
More information about the Mapserver-west
mailing list