I have a raster layer that I want to crop to a hemisphere centered on 30°N, 100°W, to use in an orthographic projection map. What is the best way to do this?

There doesn't seem to be an easy way to generate a hemisphere polygon to mask it by (which I'd think would be the obvious solution).

(Note that, unlike the question this is marked a duplicate of, this is asking about raster layers; the solutions presented in that question are for vector layers and do not work here.)


Similar to my answer in Where did the polygons go after projecting a map in QGIS? you can convert a WGS84 raster of bluemarble to an ortho projection with this command:

gdalwarp -overwrite -dstnodata 0 -ot Byte -s_srs "+proj=longlat +R=6371000" -t_srs "+proj=ortho +lat_0=30 +lon_0=-100 +x_0=0 +y_0=0 +R=6371000 +units=m +no_defs" -ts 6476 6476 -of GTiff -wo SOURCE_EXTRA=500 bluemarble.tif bluemarble-ortho.tif

The result looks like this:

enter image description here

You get a small artefact at the 180° meridian.

  • 1
    Ahh so that's how you made your avatar...nice ;) – Joseph Aug 15 '17 at 11:08
  • Huh. When I did this inside QGIS, I got a lot of artifacts at the edges (also at the poles, but I wasn't terribly surprised by that). I'll try again using gdal directly. – futuraprime Aug 15 '17 at 12:02
  • I get some errors on the command line, but gdalwarp continues to work. Maybe QGIS gives up at that point. – AndreJ Aug 15 '17 at 12:14
  • try experimenting with the SOURCE_EXTRA value included in this answer. I think it may depend on the size of your raster, try increasing it . Worth a try, I've found this option has fixed similar gaps in the past. I see a few examples in my history with much higher values. – Steven Kay Aug 15 '17 at 19:54
  • @StevenKay I tried higher values, but strangely got even more error messages. It might really depend on the image size in pixels. – AndreJ Aug 16 '17 at 5:27

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.