Create Day Night Shapefile in QGIS

Creating a shapefile that displays areas of night and day on the globe at a given time and date was something I had trouble finding help for.

I suspect the Worldwide Night plugin might do exactly this, but it requires the Matplotlib Basemap Toolkit Python library and unfortunately there is no Mac version (that I could find).

But I came up with a workaround.

In my last post I referred to this excellent post by Hamish Campbell: http://polemic.nz/2014/11/21/nz-azimuth-orthographic/

After you follow the initial steps during  Section 2. Fixing artifacts, you will generate a shapefile. This shapefile covers the half of the globe centred on the latitude and longitude you feed into the clipper command.

So if you know the position of the Sun relative to the earth (http://www.timeanddate.com/worldclock/sunearth.html is a handy resource for this), you can plug the opposite latitude and longitude into your clipper commands to generate a shapefile that covers the half of the earth opposite to the Sun’s position, i.e. the half of the earth in darkness. (Make sure you simplify your rendering to view it)

Screen Shot 2016-04-08 at 10.20.50 PM

Gray circle is output shapefile of Clipper script displayed on Azimuth Orthogrpahic Projection (the strange bands are caused by the projection and aren’t a worry for what I’m doing in this post as far as I can tell)

Then if you change your project projection to one such as WGS 84 you will see your shapefile covering (roughly) the areas of the Earth where it is night at your chosen position of the Sun.

Screen Shot 2016-04-08 at 10.18.42 PM

The same shapefile displayed on WGS 84 Projection

The shapefile still displayed some odd behaviours when changing map scale and position etc.

Selecting the polygon and saving it as a new shapefile and then also thickening the band along the south by adding vertices and moving them south seemed to fix this for me. How appropriate these last steps are will obviously depend on what you are using this for/ how you plan on displaying it.

Obviously this doesn’t account for areas of dawn and dusk and is only a rough representation, but as a quick and relatively easy fix it gives you a decent enough display of areas of day and night on the Earth.

Again, credit is also due to http://thematicmapping.org/ for the world map shapefile.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s