[gdal-dev] Re: cropping a tif with lat/lon

Brian Wilson brian at wildsong.biz
Wed Apr 20 18:24:05 EDT 2011


I am a newby too so I will share what I have learned lately. You can convert
from one srs to the other using the cs2cs tool from proj.4 which is probably
already installed if you have gdal.

To test it I typed this lengthy command all

cs2cs +proj=lcc +lat_1=44.33333333333334 +lat_2=46 +lat_0=43.66666666666666
\
+lon_0=-120.5 +x_0=2500000 +y_0=0 +ellps=GRS80 +units=m +to +proj=latlong \
+datum=WGS84

The program starts listening on stdin and I can feed it coordinate pairs in
meters for my neighborhood by typing this on a line and hitting "Enter".
2280696 101184

It responds on stdout with the pair converted to latlong as I have
requested..
123d15'36.84"W  44d32'36.644"N 0.000

Next I use control-D to exit. Then I can go the other direction by adding
the -'I' option to the cs2cs command and I feed it the latlong pair. ('-I'
just saves me some typing.)  It responded with
2280696.01      101184.01 0.00

This is reasonably close to what I started with. (What's 1 cm among
friends?)

To make it work, you would have to know the projection that your FAA chart
is in (UTM zone something right?), convert it into the funny format that
proj.4 understands, and build a command line. Then you could put your
latlong corners into a file, feed them into cs2cs, get the corners back in
the FAA space and feed them to the gdal command. Taking a stab at it, for
zone 10N where I live I would try this

+proj=utm +zone=10 +north +ellps=GRS80 +units=m

I looked up the projection stuff with grep because I happen to know the EPSG
code for it is 102326. Then I cut and pasted. The latlong part came from
google and the cs2cs manpage.

grep 102326 /usr/local/share/proj/esri
<102326> +proj=lcc +lat_1=44.33333333333334 +lat_2=46
+lat_0=43.66666666666666 +lon_0=-120.5 +x_0=2500000 +y_0=0 +ellps=GRS80
+units=m  no_defs <>

Anyway - if I needed to do this TODAY that's what I would do because it's
now in my meager skill set. Someone inspired by my clumsiness might be
inspired now to chime in with a more elegant way to do this.

Hope this helps

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110420/e7651a07/attachment.html


More information about the gdal-dev mailing list