feat: add count in bernReligionMap

This commit is contained in:
2026-06-18 18:07:11 +02:00
parent fd3665c73d
commit 35bf90aa0c
6 changed files with 52 additions and 14 deletions
@@ -0,0 +1 @@
{"_default": {"1": {"date": "2026-01-01", "religionCount": {"1-1": 270, "1-2": 2, "1-3": 1, "1-4": 11, "1-5": 73, "1-6": 4, "1-7": 4, "1-8": 3, "1-9": 186, "1-10": 10, "1-11": 26, "2-12": 16, "2-13": 1, "2-14": 2, "3-15": 3, "3-16": 9, "3-17": 7, "3-18": 3, "4-0": 8, "5-0": 2, "6-0": 2, "7-0": 1, "8-0": 2, "9-0": 2}}}}
@@ -2,7 +2,7 @@
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
<id>https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/feed/atom/de/gotteshauserNachReligionImKantonBern</id>
<title>Gotteshäuser nach Religion im Kanton Bern</title>
<updated>2026-06-18T14:56:22.734774+02:00</updated>
<updated>2026-06-18T18:06:22.013240+02:00</updated>
<author>
<name>ReSSPublica</name>
</author>
@@ -13,7 +13,7 @@
<id>1767265200.0</id>
<title>Gotteshäuser nach Religion im Kanton Bern-2026-01-01</title>
<updated>2026-01-01T00:00:00+01:00</updated>
<content type="html">&lt;img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-de-2026-01-01-2026-04-30.png" alt="Gotteshäuser nach Religion im Kanton Bern 2026-01-01"&gt;</content>
<content type="html">&lt;img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-de-2026-01-01-2026-04-30.png" alt="Gotteshäuser nach Religion im Kanton Bern 2026-01-01"&gt;evangelisch-reformiert (christlich): 270&lt;br&gt;lutherisch (christlich): 2&lt;br&gt;anglikanisch (christlich): 1&lt;br&gt;evangelische Migrationskirche (christlich): 11&lt;br&gt;römisch-katholisch (christlich): 73&lt;br&gt;christkatholisch (christlich): 4&lt;br&gt;orthodox (christlich): 4&lt;br&gt;orientalisch-orthodox (christlich): 3&lt;br&gt;freikirchlich (christlich): 186&lt;br&gt;mennonitisch (christlich): 10&lt;br&gt;christlich, weitere (christlich): 26&lt;br&gt;sunnitisch (islamisch): 16&lt;br&gt;schiitisch (islamisch): 1&lt;br&gt;islamisch, weitere (islamisch): 2&lt;br&gt;Theravada (buddhistisch): 3&lt;br&gt;Mahayana (buddhistisch): 9&lt;br&gt;Vajrayana (buddhistisch): 7&lt;br&gt;buddhistisch, weitere (buddhistisch): 3&lt;br&gt;hinduistisch: 8&lt;br&gt;jüdisch: 2&lt;br&gt;alevitisch: 2&lt;br&gt;Sikh: 1&lt;br&gt;Bahai: 2&lt;br&gt;weitere: 2&lt;br&gt;</content>
<published>2026-01-01T00:00:00+01:00</published>
</entry>
</feed>
@@ -2,7 +2,7 @@
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
<id>https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/feed/atom/fr/lieuDeCulteParReligionDansLeCantonDeBerne</id>
<title>Lieu de culte par religion dans le canton de Berne</title>
<updated>2026-06-18T14:56:22.733812+02:00</updated>
<updated>2026-06-18T18:06:22.012315+02:00</updated>
<author>
<name>ReSSPublica</name>
</author>
@@ -13,7 +13,7 @@
<id>1767265200.0</id>
<title>Lieu de culte par religion dans le canton de Berne-2026-01-01</title>
<updated>2026-01-01T00:00:00+01:00</updated>
<content type="html">&lt;img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-fr-2026-01-01-2026-04-30.png" alt="Lieu de culte par religion dans le canton de Berne 2026-01-01"&gt;</content>
<content type="html">&lt;img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-fr-2026-01-01-2026-04-30.png" alt="Lieu de culte par religion dans le canton de Berne 2026-01-01"&gt;réformé évangélique (Christianisme): 270&lt;br&gt;luthérien (Christianisme): 2&lt;br&gt;anglican (Christianisme): 1&lt;br&gt;évangélique, église de la migration (Christianisme): 11&lt;br&gt;catholique romain (Christianisme): 73&lt;br&gt;catholique chrétien (Christianisme): 4&lt;br&gt;orthodoxe (Christianisme): 4&lt;br&gt;orthodoxe oriental (Christianisme): 3&lt;br&gt;église libre (Christianisme): 186&lt;br&gt;mennonite (Christianisme): 10&lt;br&gt;autre (Christianisme): 26&lt;br&gt;sunnite (Islam): 16&lt;br&gt;chiite (Islam): 1&lt;br&gt;autre (Islam): 2&lt;br&gt;theravada (Bouddhisme ): 3&lt;br&gt;mahayana (Bouddhisme ): 9&lt;br&gt;vajrayana (Bouddhisme ): 7&lt;br&gt;autre (Bouddhisme ): 3&lt;br&gt;Hindouisme: 8&lt;br&gt;Judaïsme: 2&lt;br&gt;Alévisme: 2&lt;br&gt;Sikhisme: 1&lt;br&gt;Bahaïsme: 2&lt;br&gt;Autre tradition: 2&lt;br&gt;</content>
<published>2026-01-01T00:00:00+01:00</published>
</entry>
</feed>
@@ -8,10 +8,10 @@
<docs>https://github.com/tomasriveral/ReSSPublica</docs>
<generator>python-feedgen</generator>
<language>de</language>
<lastBuildDate>Thu, 18 Jun 2026 14:56:22 +0200</lastBuildDate>
<lastBuildDate>Thu, 18 Jun 2026 18:06:22 +0200</lastBuildDate>
<item>
<title>Gotteshäuser nach Religion im Kanton Bern-2026-01-01</title>
<description>&lt;img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-de-2026-01-01-2026-04-30.png" alt="Gotteshäuser nach Religion im Kanton Bern 2026-01-01"&gt;</description>
<description>&lt;img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-de-2026-01-01-2026-04-30.png" alt="Gotteshäuser nach Religion im Kanton Bern 2026-01-01"&gt;evangelisch-reformiert (christlich): 270&lt;br&gt;lutherisch (christlich): 2&lt;br&gt;anglikanisch (christlich): 1&lt;br&gt;evangelische Migrationskirche (christlich): 11&lt;br&gt;römisch-katholisch (christlich): 73&lt;br&gt;christkatholisch (christlich): 4&lt;br&gt;orthodox (christlich): 4&lt;br&gt;orientalisch-orthodox (christlich): 3&lt;br&gt;freikirchlich (christlich): 186&lt;br&gt;mennonitisch (christlich): 10&lt;br&gt;christlich, weitere (christlich): 26&lt;br&gt;sunnitisch (islamisch): 16&lt;br&gt;schiitisch (islamisch): 1&lt;br&gt;islamisch, weitere (islamisch): 2&lt;br&gt;Theravada (buddhistisch): 3&lt;br&gt;Mahayana (buddhistisch): 9&lt;br&gt;Vajrayana (buddhistisch): 7&lt;br&gt;buddhistisch, weitere (buddhistisch): 3&lt;br&gt;hinduistisch: 8&lt;br&gt;jüdisch: 2&lt;br&gt;alevitisch: 2&lt;br&gt;Sikh: 1&lt;br&gt;Bahai: 2&lt;br&gt;weitere: 2&lt;br&gt;</description>
<guid isPermaLink="false">1767265200.0</guid>
<pubDate>Thu, 01 Jan 2026 00:00:00 +0100</pubDate>
</item>
@@ -8,10 +8,10 @@
<docs>https://github.com/tomasriveral/ReSSPublica</docs>
<generator>python-feedgen</generator>
<language>fr</language>
<lastBuildDate>Thu, 18 Jun 2026 14:56:22 +0200</lastBuildDate>
<lastBuildDate>Thu, 18 Jun 2026 18:06:22 +0200</lastBuildDate>
<item>
<title>Lieu de culte par religion dans le canton de Berne-2026-01-01</title>
<description>&lt;img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-fr-2026-01-01-2026-04-30.png" alt="Lieu de culte par religion dans le canton de Berne 2026-01-01"&gt;</description>
<description>&lt;img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-fr-2026-01-01-2026-04-30.png" alt="Lieu de culte par religion dans le canton de Berne 2026-01-01"&gt;réformé évangélique (Christianisme): 270&lt;br&gt;luthérien (Christianisme): 2&lt;br&gt;anglican (Christianisme): 1&lt;br&gt;évangélique, église de la migration (Christianisme): 11&lt;br&gt;catholique romain (Christianisme): 73&lt;br&gt;catholique chrétien (Christianisme): 4&lt;br&gt;orthodoxe (Christianisme): 4&lt;br&gt;orthodoxe oriental (Christianisme): 3&lt;br&gt;église libre (Christianisme): 186&lt;br&gt;mennonite (Christianisme): 10&lt;br&gt;autre (Christianisme): 26&lt;br&gt;sunnite (Islam): 16&lt;br&gt;chiite (Islam): 1&lt;br&gt;autre (Islam): 2&lt;br&gt;theravada (Bouddhisme ): 3&lt;br&gt;mahayana (Bouddhisme ): 9&lt;br&gt;vajrayana (Bouddhisme ): 7&lt;br&gt;autre (Bouddhisme ): 3&lt;br&gt;Hindouisme: 8&lt;br&gt;Judaïsme: 2&lt;br&gt;Alévisme: 2&lt;br&gt;Sikhisme: 1&lt;br&gt;Bahaïsme: 2&lt;br&gt;Autre tradition: 2&lt;br&gt;</description>
<guid isPermaLink="false">1767265200.0</guid>
<pubDate>Thu, 01 Jan 2026 00:00:00 +0100</pubDate>
</item>
+43 -6
View File
@@ -28,12 +28,6 @@ def generateBernReligionMap(ASSETS, CACHE):
logger.info("Generating Religion map in Bern feed...")
logger.info("Preparing data...")
#ASIAN_HORNETS_DB_PATH = CACHE / "bernAsianHornet.json"
#global db
#global q
#db = TinyDB(ASIAN_HORNETS_DB_PATH)
#q = Query()
# 1. Load data
url = "https://geofiles.be.ch/geoportal/pub/download/RELIGION/religion_relstaet.parquet"
@@ -101,6 +95,40 @@ def generateBernReligionMap(ASSETS, CACHE):
)
logger.debug(religions)
# we generate the count by each religion and store it in a database to log changes.
BERN_RELIGION_MAP_DB_PATH = CACHE / "bernReligionMapByReligionCount.json"
db = TinyDB(BERN_RELIGION_MAP_DB_PATH)
q = Query()
for start, end in trimesterRangesFrom(arbitraryStartDate):
if db.contains(q.date == start.isoformat()):
continue # we already calculated the entry for this date. We skip it.
dbEntry = {
"date": start.isoformat(),
"religionCount": {}
}
# initialize with default values
for religionID in religions.keys():
dbEntry["religionCount"][str(religionID)] = 0
# count
for placeOfWorship in religionGeoDataFrame.itertuples():
# again we must check against religions that don't have nkenn information
try:
placeOfWorship.nkenn_id
dbEntry["religionCount"][f"{placeOfWorship.reltra_id}-{str(placeOfWorship.nkenn_id).split(".")[0]}"] += 1
except:
dbEntry["religionCount"][f"{placeOfWorship.reltra_id}-0"] += 1
logger.info("Religion Count")
logger.info(dbEntry["religionCount"])
db.upsert(dbEntry, q.date == start.isoformat())
# we generate the map(s) now
# generate color palette (1 color by religion with similar religion similar color)
palette = color_palette("husl", len(religions.keys()))
color_map = {
@@ -248,10 +276,19 @@ def generateBernReligionMap(ASSETS, CACHE):
trimestrialEntry["date"] = start.isoformat() # there is no point have them different. On other feeds it's used for update date
trimestrialEntry["source"] = "opendata.swiss"
countDataBase = db.get(q.date == start.isoformat())["religionCount"]
for lang in ["fr", "de"]:
trimestrialEntry["url"] = f"https://opendata.swiss/{lang}/dataset/religionslandkarte"
trimestrialEntry["title"] = f"{translatedPlacesOfWorshipInBern[lang]}-{start.isoformat()}"
trimestrialEntry["text"] = f"<img src=\"https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-{lang}-{start.isoformat()}-{end.isoformat()}.png\" alt=\"{translatedPlacesOfWorshipInBern[lang]} {start.isoformat()}\">"
for religionID in religions.keys():
if religionID[2] == "0": # that means there is no nkenn
trimestrialEntry["text"] += f"{religions[religionID][f"reltrat_reltra_{lang}"]}: {countDataBase[religionID]}<br>"
else:
trimestrialEntry["text"] += f"{religions[religionID][f"nkennt_nkenn_{lang}"]} ({religions[religionID][f"reltrat_reltra_{lang}"]}): {countDataBase[religionID]}<br>"
feeds[lang].append(copy.deepcopy(trimestrialEntry))
generateFeed(
translatedPlacesOfWorshipInBern["fr"],