DMUG-Archiv 2020

Frühere   Chronologischer Index   Spätere
Vorherige   Thematischer Index   Nächste

[Dmug] CityData

Liebe Freundinnen und Freunde neuer Mathematicafähigkeiten,


Mathematica bietet umfangreiche Geodaten, darunter 164'601 Einträge in CityData[].

Ortsnamen wiederholen sich auf der Erde und man kann fragen, in wievielen verschiedenen Ländern derselbe Ortsname vorkommt; ein Beispiel - leider nicht mit Mathematica herausgefunden - ist der Name "Santa Maria":

In[1]:= Tally[EntityClass["City", "Name" -> "Santa Maria"]["Country"]]

Out[1]= {{Entity["Country", "Brazil"],
  1}, {Entity["Country", "UnitedStates"],
  2}, {Entity["Country", "Philippines"],
  11}, {Entity["Country", "Peru"],
  1}, {Entity["Country", "CapeVerde"],
  1}, {Entity["Country", "Chile"], 1}, {Entity["Country", "Colombia"],
   2}, {Entity["Country", "Paraguay"],
  1}, {Entity["Country", "Panama"],
  1}, {Entity["Country", "Honduras"],
  2}, {Entity["Country", "CostaRica"],
  1}, {Entity["Country", "Nicaragua"], 1}}

In[5]:= (* Anzahl der Länder *)
Length[%1]

Out[5]= 12

da werden 12 Länder gemeldet.

Man kann weiter fragen, wie die über die Anzahl der Länder graduierten Maxima aussehen, also welcher Name erscheint am meisten unter den Namen, die in n Ländern auftreten. Wie kann man diese Frage in Mathematica stellen?

Nach einer Reihe trister Anzeigen, die besagten, dass die Daten erneut geladen werden und nach überaus wüsten Verarbeitungszeiten ohne Ergebnis wurde der Datensatz nach PostgreSQL importiert, wo das Query

select Q2.name, Q2.cities, Q2.countries
from
(
select q1.name, q1.cities, q1.countries,
rank() over ( partitionby q1.countries order by q1.cities desc) as rk
from
    (
select q.name, sum( q.count) as cities, count(*) as countries
FROM
        (
select c.name, c.country, count(*)
from   joey.citydata c
group by c.name, c.country
        ) as Q
group by Q.name
order by cities desc, countries desc
    ) as Q1
) as Q2
where Q2.rk = 1
order by Q2.countries desc;

in Sekundenschnelle die Antwort

/*
" SantaMaria";  26;13
" SanPedro";    24;12
" Victoria";    24;12
" SanJose";     28;11
" SantaCruz";   28;11
" SanMiguel";   28;10
" SanFrancisco";27;9
" SanJuan";     20;8
" Richmond";    30;7
" Wellington";  17;6
" Cambridge";   18;5
" Salem";       28;4
" Clinton";     28;3
" Springfield"; 25;2
" Franklin";    28;1
 */

gibt. Aha - demnach kommt 'SantaMaria' in 13 Ländern vor, nicht in 12. Das dreizehnte Land ist Rumänien, woran das nächste Problem sichtbar wird. Das dortige 'SantaMaria' liegt in der Region (Regierungsbezirk) 'Botosani':

In[12]:= CityData[{All, "Botosani", "Romania"}]

Out[12]= {Entity["City", {"Botosani", "Botosani", "Romania"}],
 Entity["City", {"Dorohoi", "Botosani", "Romania"}],
 Entity["City", {"Flamanzi", "Botosani", "Romania"}],
 Entity["City", {"Darabani", "Botosani", "Romania"}],
 Entity["City", {"Saveni", "Botosani", "Romania"}],
 Entity["City", {"Vorona", "Botosani", "Romania"}],
 Entity["City", {"Copalau", "Botosani", "Romania"}],
 Entity["City", {"Ungureni", "Botosani", "Romania"}],
 Entity["City", {"Albesti", "Botosani", "Romania"}],
 Entity["City", {"Corni", "Botosani", "Romania"}],
 Entity["City", {"MihailEminescu", "Botosani", "Romania"}],
 Entity["City", {"Hudesti", "Botosani", "Romania"}],
 Entity["City", {"Frumusica", "Botosani", "Romania"}],
 Entity["City", {"Stefanesti", "Botosani", "Romania"}],
 Entity["City", {"Trusesti", "Botosani", "Romania"}],
 Entity["City", {"SuliTa", "Botosani", "Romania"}],
 Entity["City", {"Avrameni", "Botosani", "Romania"}],
 Entity["City", {"Suharau", "Botosani", "Romania"}],
 Entity["City", {"CoTusca", "Botosani", "Romania"}],
 Entity["City", {"Bucecea", "Botosani", "Romania"}],
 Entity["City", {"Tudora", "Botosani", "Romania"}],
 Entity["City", {"Dersca", "Botosani", "Romania"}],
 Entity["City", {"Havarna", "Botosani", "Romania"}],
 Entity["City", {"Mihaileni", "Botosani", "Romania"}],
 Entity["City", {"Baluseni", "Botosani", "Romania"}],
 Entity["City", {"Vladeni", "Botosani", "Romania"}],
 Entity["City", {"Lunca", "Botosani", "Romania"}],
 Entity["City", {"Cristesti", "Botosani", "Romania"}],
 Entity["City", {"Vorniceni", "Botosani", "Romania"}],
 Entity["City", {"RachiTi", "Botosani", "Romania"}],
 Entity["City", {"Curtesti", "Botosani", "Romania"}],
 Entity["City", {"Sendriceni", "Botosani", "Romania"}],
 Entity["City", {"Ibanesti", "Botosani", "Romania"}],
 Entity["City", {"Durnesti", "Botosani", "Romania"}],
 Entity["City", {"Corlateni", "Botosani", "Romania"}],
 Entity["City", {"Calarasi", "Botosani", "Romania"}],
 Entity["City", {"RadauTiPrut", "Botosani", "Romania"}],
 Entity["City", {"VarfuCampului", "Botosani", "Romania"}],
 Entity["City", {"Cristinesti", "Botosani", "Romania"}],
 Entity["City", {"Hlipiceni", "Botosani", "Romania"}],
 Entity["City", {"Manoleasa", "Botosani", "Romania"}],
 Entity["City", {"HiliseuHoria", "Botosani", "Romania"}],
 Entity["City", {"GeorgeEnescu", "Botosani", "Romania"}],
 Entity["City", {"Gorbanesti", "Botosani", "Romania"}],
 Entity["City", {"Todireni", "Botosani", "Romania"}],
 Entity["City", {"BroscauTi", "Botosani", "Romania"}],
 Entity["City", {"Vlasinesti", "Botosani", "Romania"}],
 Entity["City", {"Paltinis", "Botosani", "Romania"}],
 Entity["City", {"Stauceni", "Botosani", "Romania"}],
 Entity["City", {"Prajeni", "Botosani", "Romania"}],
 Entity["City", {"Roma", "Botosani", "Romania"}],
 Entity["City", {"Dangeni", "Botosani", "Romania"}],
 Entity["City", {"SantaMaria", "Botosani", "Romania"}],
 Entity["City", {"UnTeni", "Botosani", "Romania"}],
 Entity["City", {"Rauseni", "Botosani", "Romania"}],
 Entity["City", {"Mileanca", "Botosani", "Romania"}],
 Entity["City", {"Pomarla", "Botosani", "Romania"}],
 Entity["City", {"Dobarceni", "Botosani", "Romania"}],
 Entity["City", {"Nicseni", "Botosani", "Romania"}],
 Entity["City", {"Stiubieni", "Botosani", "Romania"}],
 Entity["City", {"Draguseni", "Botosani", "Romania"}],
 Entity["City", {"Leorda", "Botosani", "Romania"}],
 Entity["City", {"Mihalaseni", "Botosani", "Romania"}],
 Entity["City", {"Hanesti", "Botosani", "Romania"}],
 Entity["City", {"Viisoara", "Botosani", "Romania"}],
 Entity["City", {"Ripiceni", "Botosani", "Romania"}],
 Entity["City", {"Vaculesti", "Botosani", "Romania"}],
 Entity["City", {"Braesti", "Botosani", "Romania"}],
 Entity["City", {"Romanesti", "Botosani", "Romania"}],
 Entity["City", {"Cordareni", "Botosani", "Romania"}],
 Entity["City", {"Concesti", "Botosani", "Romania"}],
 Entity["City", {"Mitoc", "Botosani", "Romania"}]}


ein glasklares "SantaMaria", in der Anzeige erscheint es als "Santa-Maria", siehe bitte das beigelegte Bildchen, aber weder mit dem normalisierten Namen noch mit dem Anzeigenamen wird's in Rumänien gefunden:


In[13]:= Tally[EntityClass["City", "Name" -> "Santa-Maria"]["Country"]]
Out[13]= {}

In[14]:= Tally[EntityClass["City", "Name" -> "SantaMaria"]["Country"]]
Out[14]= {}



Mit den besten Grüssen

Udo.




Attachment: Santa-Maria-Romania.jpg
Description: JPEG image

_______________________________________________
DMUG Deutschsprachiges Mathematica-Forum demug@XXXXXXX.ch
http://www.mathematica.ch/mailman/listinfo/demug
Archiv: http://www.mathematica.ch/archiv.html
Frühere   Chronologischer Index   Spätere
Vorherige   Thematischer Index   Nächste

DMUG DMUG-Archiv, http://www.mathematica.ch/archiv.html