I want to plot data from a sensor raster file (tif) to a map using basemap. I have a geotif with 'WGS 84'

>>> gtif = gdal.Open("example.tif")
>>> print gtif.GetProjectionRef()
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],

My map is using 'merc'

>>> m = Basemap(projection='merc', llcrnrlat=-26, urcrnrlat=48, llcrnrlon=-28, urcrnrlon=42, lat_ts=20, resolution='c')

How can I convert the tif in the merc projection?


Using gdal.

Have a look at gdal_translate to convert to from tif to another format (although the tif is likely the best option).

Then use gdalwarp to reproject to mercator.

Gdal is written in python so you should be able to incorporate it straight into your workflow.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.