Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

Converting horizon files in Stellarium or Cartes du Ciel to KStars

  1. Home

By Khalid on 2017/07/19 - 10:32, last updated 2017/07/25 - 22:56

Using a planetarium program is a very common thing for any amateur astronomer. I use three such programs, namely: Stellarium, Cartes du Ciel (SkyCharts), and KStars.

Both Stellarium and Cartes du Ciel support a simple scheme to add obstructions in your location to their dynamically generated maps of the sky. This scheme relies on you created a simple file with two columns. The first column is the Asimuth (the degrees of the horizon's offset from 0 for north, 90 for east, 180 for south and 270 for west. Each program interpolates the horizon line from the previous and following azimuth points.

KStars however, does not have the same scheme. It uses a rudimentary editor to 'draw' the horizon using a mouse. The limitation is that you have to add a full polygon for each obstruction.

So, I sought a way to convert the simpler horizon file from Stellarium and Cartes du Ciel into KStars.

I did this by looking at the data structure inside the main database that KStars uses. It is an SQLite 3 database, and hence easy to understand.

Here is an example of a horizon file. Yes, this has lots of obstructions!

00 10
02 10
05 40
10 55
20 62
40 55
42 50
45 15
50 15
60 15
70 15
80 3
90 3
100 15
120 15
129 3
130 27
132 27
134 3
140 5
150 55
160 55
170 55
190 15
200 25
210 15
220 13
230 13
235 23
250 25
260 25
265 25
270 27
275 25
280 20
285 25
290 25
300 25
350 35
351 10
355 10
359 10

We now need to delete any existing tables, and replace then by new empty ones containing azimuth/altitude pairs.
The only limitation is that you have to start an obstruction at zero altitude, and end it at zero altitude as well:

-- Remove any existing tables
DROP TABLE horizon_1;
DROP TABLE horizon_2;
DROP TABLE horizon_3;
DROP TABLE horizon_4;

DROP TABLE horizons;

-- Create the main table
CREATE TABLE horizons (
  id      INTEGER DEFAULT NULL PRIMARY KEY AUTOINCREMENT,
  name    TEXT    NOT NULL,
  label   TEXT    NOT NULL,
  enabled INTEGER NOT NULL);

-- Create four horizon files, one for each quadrant of the azimuth circle
CREATE TABLE horizon_1 (Az REAL NOT NULL, Alt REAL NOT NULL);
CREATE TABLE horizon_2 (Az REAL NOT NULL, Alt REAL NOT NULL);
CREATE TABLE horizon_3 (Az REAL NOT NULL, Alt REAL NOT NULL);
CREATE TABLE horizon_4 (Az REAL NOT NULL, Alt REAL NOT NULL);

INSERT INTO "horizons" VALUES (1, 'horizon_1', 'Region 1',1);
INSERT INTO "horizons" VALUES (2, 'horizon_2', 'Region 2',1);
INSERT INTO "horizons" VALUES (3, 'horizon_3', 'Region 3',1);
INSERT INTO "horizons" VALUES (4, 'horizon_4', 'Region 4',1);

-- Now insert the values in each horizon quadrant
-- The first value is the Azimuth, the second is the Altitude
-- Remember that you have to start an area from zero altitude
-- and also end with zero altitude

-- First quadrant, from north to east
INSERT INTO "horizon_1" VALUES(0, 0);
INSERT INTO "horizon_1" VALUES(1, 10);
INSERT INTO "horizon_1" VALUES(2, 10);
INSERT INTO "horizon_1" VALUES(5, 40);
INSERT INTO "horizon_1" VALUES(10, 55);
INSERT INTO "horizon_1" VALUES(20, 62);
INSERT INTO "horizon_1" VALUES(40, 55);
INSERT INTO "horizon_1" VALUES(42, 50);
INSERT INTO "horizon_1" VALUES(45, 15);
INSERT INTO "horizon_1" VALUES(50, 15);
INSERT INTO "horizon_1" VALUES(60, 15);
INSERT INTO "horizon_1" VALUES(70, 15);
INSERT INTO "horizon_1" VALUES(80, 3);
INSERT INTO "horizon_1" VALUES(89, 3);
INSERT INTO "horizon_1" VALUES(90, 0);

-- Second quadrant, from east to south
INSERT INTO "horizon_2" VALUES(100, 0);
INSERT INTO "horizon_2" VALUES(101, 15);
INSERT INTO "horizon_2" VALUES(120, 15);
INSERT INTO "horizon_2" VALUES(129, 3);
INSERT INTO "horizon_2" VALUES(130, 27);
INSERT INTO "horizon_2" VALUES(132, 27);
INSERT INTO "horizon_2" VALUES(134, 3);
INSERT INTO "horizon_2" VALUES(140, 5);
INSERT INTO "horizon_2" VALUES(150, 55);
INSERT INTO "horizon_2" VALUES(160, 55);
INSERT INTO "horizon_2" VALUES(169, 55);
INSERT INTO "horizon_2" VALUES(170, 0);

-- Third quadrant, from south to west
INSERT INTO "horizon_3" VALUES(190, 0);
INSERT INTO "horizon_3" VALUES(191, 15);
INSERT INTO "horizon_3" VALUES(200, 25);
INSERT INTO "horizon_3" VALUES(210, 15);
INSERT INTO "horizon_3" VALUES(220, 13);
INSERT INTO "horizon_3" VALUES(230, 13);
INSERT INTO "horizon_3" VALUES(235, 23);
INSERT INTO "horizon_3" VALUES(250, 25);
INSERT INTO "horizon_3" VALUES(260, 25);
INSERT INTO "horizon_3" VALUES(265, 25);
INSERT INTO "horizon_3" VALUES(269, 27);
INSERT INTO "horizon_3" VALUES(270, 0);

-- Fourth quadrant, from west to north
INSERT INTO "horizon_4" VALUES(275, 0);
INSERT INTO "horizon_4" VALUES(276, 25);
INSERT INTO "horizon_4" VALUES(280, 20);
INSERT INTO "horizon_4" VALUES(285, 25);
INSERT INTO "horizon_4" VALUES(290, 25);
INSERT INTO "horizon_4" VALUES(300, 25);
INSERT INTO "horizon_4" VALUES(350, 35);
INSERT INTO "horizon_4" VALUES(351, 10);
INSERT INTO "horizon_4" VALUES(355, 10);
INSERT INTO "horizon_4" VALUES(358, 10);
INSERT INTO "horizon_4" VALUES(359, 0);

Store the above file in a .sql file.

Then exit KStars.

And run the SQL file as follows:

sqlite3 ~/.local/share/kstars/userdb.sqlite < create-horizon.sql 

When you start KStars, you should see your new horizon. It will not look exactly as it did in Stellarium or Cartes du Ciel, so you may need to refine it by adding more azimuth/altitude points.

Contents: 
Astronomy
  • Add comment

Current

Pandemic

  • COVID-19
  • Coronavirus

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • Origin Of COVID-19: Natural Spillover, Lab Leak Or Biological Weapon?
  • Kamal Salibi and the "Israel from Yemen" theory
  • How To Upgrade HomeAssistant Core In A Python Venv Using uv
  • Ancestry - Paternal Side
  • Review of Wait Water Saver For Whole House Humidifiers
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

Android Mobile Ubuntu Sony OnStep OpenWRT Router Ericsson COVID-19 Rogers Coronavirus Arabic Kubuntu Home Assistant GSM Telescope tablet Spectrum Scam Python 419 Laptop Firefox DIY CPU Conspiracy Comet Balkanization backup App
More

© Copyright 1999-2025 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.