File:Wiki commons de animation 1990-2022.gif

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (933 × 818 pixels, file size: 1.24 MB, MIME type: image/gif, looped, 33 frames, 6.6 s)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
Deutsch: Bilder Koordinaten Entwicklung in Deutschland über die Jahre (nach Erstellungsdatum des Bildes)
Date
Source Own work
Author Laserlicht

Generator
from SPARQLWrapper import SPARQLWrapper, XML

#https://wcqs-beta.wmflabs.org
def query(x1, y1, x2, y2):
    queryString = """
        SELECT ?fileLabel ?image ?coor ?date
        WHERE
        {
        hint:Query hint:optimizer "None".
        SERVICE wikibase:box {
            ?file wdt:P1259 ?coor.
            bd:serviceParam wikibase:cornerWest "Point(""" + str(y1) + """ """ + str(x1) + """)"^^geo:wktLiteral.
            bd:serviceParam wikibase:cornerEast "Point(""" + str(y2) + """ """ + str(x2) + """)"^^geo:wktLiteral.
        }  
        ?file schema:contentUrl ?url;
                wdt:P571 ?date.
        bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/", wikibase:decodeUri(substr(str(?url),53)))) AS ?image)  
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
        }
    """
    sparql = SPARQLWrapper("https://wcqs-beta.wmflabs.org/sparql")

    sparql.setReturnFormat(XML)
    sparql.setQuery(queryString)

    return str(sparql.query().response.read().decode("utf-8"))
data_str = []

for y in range(47, 55 + 1):
    for x in range(5, 15 + 1):
        data_str.append(query(y, x, y + 1, x + 1))

#-----------------------------------------------------------------------------------------

import pandas as pd

df_concat = None
for dstr in data_str:
    df = pd.read_xml(dstr, xpath="//*[contains(name(),'binding')]", elems_only=True)

    df = df.stack().reset_index()
    df = pd.concat([df[df["level_0"] % 4 == 0][0].reset_index(), df[df["level_0"] % 4 == 1][0].reset_index(), df[df["level_0"] % 4 == 2][0].reset_index(), df[df["level_0"] % 4 == 3][0].reset_index()], axis=1)[0]

    df.columns = ["Coordinate", "Date", "Dataelement", "File"]
    df["Lat"] = df["Coordinate"].str.extract(r"Point\([^ ]* ([^\)]*)\)").astype(float)
    df["Lon"] = df["Coordinate"].str.extract(r"Point\(([^ ]*).*").astype(float)

    if df_concat is None:
        df_concat = df
    else:
        df_concat = pd.concat([df_concat, df]).drop_duplicates().reset_index(drop=True)
df = df_concat

#-----------------------------------------------------------------------------------------

import reverse_geocoder as rg

tmp = tuple(zip(df["Lat"], df["Lon"]))
results = rg.search(tmp)
df["Locationname"] = [o["name"] for o in results]
df["admin1"] = [o["admin1"] for o in results]
df["admin2"] = [o["admin2"] for o in results]
df["cc"] = [o["cc"] for o in results]

#-----------------------------------------------------------------------------------------

df_processed = df

df_processed = df_processed[df_processed["cc"] == "DE"]

df_processed = df_processed[(df_processed['Date'] > '1950-01-01') & (df_processed['Date'] < '2023-01-01')]

#-----------------------------------------------------------------------------------------

from PIL import Image, ImageDraw, ImageOps
from IPython.display import display

im = Image.new("L", (1080, 1920))
pixels = im.load()

for year in range(1990, 2022 + 1):
    df_processed_ = df_processed[df_processed['Date'].astype('datetime64[D]').dt.to_period('Y') == str(year)]

    for y, x, d in df_processed_[["Lat", "Lon", "Date"]].to_numpy():
        x_ = (x-5)*100
        y_ = (y-46)*100
        pixels[x_, y_] = int(pixels[x_, y_] + 10)

    ImageOps.flip(im).save(str(year) + "_img.png", 'PNG')

im = ImageOps.flip(im)
display(im)

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current03:01, 9 January 2022Thumbnail for version as of 03:01, 9 January 2022933 × 818 (1.24 MB)Laserlicht (talk | contribs)Uploaded own work with UploadWizard

There are no pages that use this file.