[gdal-dev] Using Python gdalwarp to read gif file and world file, re-project to another picture

Guodong Zhu gd.zhu at outlook.com
Thu Mar 5 13:16:39 PST 2020


Hi Sean,

Thanks a lot for your answer! It works for me. I have one follow up question: is there a way to make the background transparent instead of being white?

I really appreciate your help!

Best regard,
Guodong


From: gdal-dev <gdal-dev-bounces at lists.osgeo.org> On Behalf Of Sean Gillies
Sent: Thursday, March 5, 2020 11:24 AM
To: gdal dev <gdal-dev at lists.osgeo.org>
Subject: Re: [gdal-dev] Using Python gdalwarp to read gif file and world file, re-project to another picture

Hi Guodong,

On Wed, Mar 4, 2020 at 9:23 PM Guodong <gd.zhu at outlook.com<mailto:gd.zhu at outlook.com>> wrote:
Hello,

I want to re-project a radar image
(https://radar.weather.gov/Conus/RadarImg/latest_radaronly.gif) which is in
NAD83/EPSG4326 to WGS84/Pseudo-Mercator/EPSG3857. There is a world file
associated with this gif
(https://radar.weather.gov/Conus/RadarImg/latest_radaronly.gfw). I was
wondering how can I do this projection using Python gdalwarp package, and
how to extract the coordinates bounds from the new re-projected picture?

I'm very new to GIS. I know world file contains georeferencing information,
but I stucked at the first step and don't know how to read gif file along
with the world file...

Thanks a lot for your time and help!

Best regards,
Guodong

If you save the .gif and the .gfw file to the same directory, so that they are siblings, GDAL will find the .gfw automatically when the .gif file is opened. This is a common GIS paradigm. Many GIS file formats are actually multi-file formats. One file, usually the image file, is the primary file and it may have auxiliary or "sidecar" files that carry additional information. A world file is one such auxiliary file.

You can convert and warp like like this:

gdalwarp -r near -s_srs EPSG:4326 -t_srs EPSG:3857 -of GTiff latest_radaronly.gif warped.tif

The gdalinfo program will show you the bounds of the result and you can confirm they are what you expect.

--
Sean Gillies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200305/7bdd46d2/attachment.html>


More information about the gdal-dev mailing list