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

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Guodong
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



--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Using Python gdalwarp to read gif file and world file, re-project to another picture

Sean Gillies-3
Hi Guodong,

On Wed, Mar 4, 2020 at 9:23 PM Guodong <[hidden email]> 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

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Using Python gdalwarp to read gif file and world file, re-project to another picture

Guodong

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 <[hidden email]> On Behalf Of Sean Gillies
Sent: Thursday, March 5, 2020 11:24 AM
To: gdal dev <[hidden email]>
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 <[hidden email]> 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


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Using Python gdalwarp to read gif file and world file, re-project to another picture

Sean Gillies-3
Hi Guodong,

On Thu, Mar 5, 2020 at 2:16 PM Guodong Zhu <[hidden email]> wrote:

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!


The background is transparent, I think it may appear white due to details of your image viewer. If you convert the warped GeoTIFF to a PNG like

gdal_translate -of PNG warped.tif warped.png

you'll have a file that looks properly transparent in a browser or image viewer.

--
Sean Gillies

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Using Python gdalwarp to read gif file and world file, re-project to another picture

Guodong

Hi Sean,

 

The background is actually not transparent : ) Just for your reference, I followed the following post and removed the background:

https://stackoverflow.com/questions/765736/using-pil-to-make-all-white-pixels-transparent

 

Thanks for your help on my question!

 

Best regards,

Guodong

From: gdal-dev <[hidden email]> On Behalf Of Sean Gillies
Sent: Friday, March 6, 2020 1:22 PM
To: gdal dev <[hidden email]>
Subject: Re: [gdal-dev] Using Python gdalwarp to read gif file and world file, re-project to another picture

 

Hi Guodong,

 

On Thu, Mar 5, 2020 at 2:16 PM Guodong Zhu <[hidden email]> wrote:

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!

 

The background is transparent, I think it may appear white due to details of your image viewer. If you convert the warped GeoTIFF to a PNG like

 

gdal_translate -of PNG warped.tif warped.png

 

you'll have a file that looks properly transparent in a browser or image viewer.

 

--

Sean Gillies


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev