Skip to content

Latest commit

 

History

History
161 lines (128 loc) · 43.9 KB

README.md

File metadata and controls

161 lines (128 loc) · 43.9 KB

Accessing speaker area data in CLDF

With version 1.3, CLDF gained a speakerArea property. And one of the first datasets that included speaker area information was a CLDF dataset derived from a digitized version of Wurm & Hattori's "Language Atlas of the Pacific Area".

Let's see what we can do with this data. This dataset contains languages located "on both sides" of the antimeridian, making things a little more interesting as described in this blogpost.

Creating GeoJSON objects via pycldf

We'll first pick three languages in the dataset which are spoken in the locations discussed in the linked blog post: Ande in Vanuatu, Fijian and Samoan.

Using pycldf and assuming a local download or clone of the dataset this could look as follows:

>>> from pycldf import Dataset
>>> ds = Dataset.from_metadata('languageatlasofthepacificarea/cldf/Generic-metadata.json')
>>> lgs = [lg for lg in ds.objects('LanguageTable') if lg.cldf.name in ['Ande', 'Fijian', 'Samoan']]
>>> lgs
[<pycldf.orm.Language id="fiji1243">, <pycldf.orm.Language id="moro1286">, <pycldf.orm.Language id="samo1305">]

Let's line them up in East-West order:

>>> lgs.sort(key=lambda lg: lg.cldf.longitude if lg.cldf.longitude > 0 else lg.cldf.longitude + 360)
>>> lgs
[<pycldf.orm.Language id="moro1286">, <pycldf.orm.Language id="fiji1243">, <pycldf.orm.Language id="samo1305">]

Note that we used a common "trick" here to handle the antimeridian problem - where longitude values switch the sign. To have Samoan as the most westward langfuage in our sample, we added just "one spin of the globe" to its longitude.

Now we can recreate the map from the blog post using GeoJSON and the fact that GitHub pages can render GeoJSON:

>>> feature_collection = {"type": "FeatureCollection", "features": []}
>>> for lg in lgs:
...     feature_collection["features"].append({"type": "Feature", "properties": {"title": lg.cldf.name}, "geometry": {"type": "Point", "coordinates": [float(lg.cldf.longitude), float(lg.cldf.latitude)]}})
...
>>> for lg in lgs:
...     feature_collection["features"].append(lg.speaker_area_as_geojson_feature)
...
>>> feature_collection["features"].append({
... "type": "Feature",
... "properties": None,
... "geometry": {
...     "type": "LineString",
...     "coordinates": [[float(lg.cldf.longitude if lg.cldf.longitude > 0 else lg.cldf.longitude + 360), float(lg.cldf.latitude)] for lg in lgs]
... }})
>>> import json
>>> print(json.dumps(feature_collection))

Note that we again applied the trick described above to make sure the line from Fijian to Samoan goes in the "right" direction.

Pasting the JSON object printed by the code above into a GitHub markdown page we get:

{"type": "FeatureCollection", "features": [{"type": "Feature", "properties": {"title": "Ande"}, "geometry": {"type": "Point", "coordinates": [166.891, -15.3498]}}, {"type": "Feature", "properties": {"title": "Fijian"}, "geometry": {"type": "Point", "coordinates": [178.33, -18.0]}}, {"type": "Feature", "properties": {"title": "Samoan"}, "geometry": {"type": "Point", "coordinates": [-171.83, -13.92]}}, {"type": "Feature", "properties": {"title": "Ande", "fill": "#CC5151", "family": "Austronesian", "cldf:languageReference": "moro1286", "fill-opacity": 0.8}, "geometry": {"type": "Polygon", "coordinates": [[[166.80147740704612, -15.3775402349157], [166.80098358313995, -15.37755088530666], [166.80049111800838, -15.377512759523645], [166.8000048176281, -15.377426229636908], [166.79952942781392, -15.377292140093276], [166.79906958790417, -15.37711179947519], [166.79862978548536, -15.376886967730208], [166.79821431259776, -15.376619838995659], [166.7978272238493, -15.376313020186002], [166.7974722968465, -15.37596950555191], [166.79715299532884, -15.375592647459303], [166.79687243536597, -15.375186123673563], [166.79663335494794, -15.37475390146814], [166.7964380872652, -15.374300198907852], [166.79628853793875, -15.373829443684718], [166.7961861664234, -15.373346229908021], [166.79613197176474, -15.372855273270307], [166.79612648284947, -15.372361365026851], [166.79616975324404, -15.37186932523771], [166.7962613606718, -15.371383955728653], [166.7964004111341, -15.370909993230061], [166.79658554763486, -15.37045206315108], [166.79681496342334, -15.370014634440164], [166.79708641962648, -15.36960197597252], [166.79739726709798, -15.369218114890076], [166.79774447227135, -15.368866797300525], [166.79812464676465, -15.368551451718984], [166.79853408044764, -15.368275155609046], [166.84000748597427, -15.343176513894031], [166.8403762378072, -15.34297404046948], [166.8407607047618, -15.342803281684269], [166.9870925169654, -15.285052218076885], [166.98755666107272, -15.284894861717172], [166.98803398082106, -15.284783701318807], [166.98851989029836, -15.28471980486989], [166.98900972106566, -15.284703786263927], [166.98949876700962, -15.284735799401775], [166.98998232955728, -15.284815536713014], [166.9904557628181, -15.284942232110978], [166.99091451821997, -15.28511466835303], [166.99135418821024, -15.285331188735373], [166.99177054860186, -15.28558971301006], [166.99215959915782, -15.285887757371238], [166.9925176020239, -15.286222458318653], [166.99284111764064, -15.286590600169085], [166.99312703778935, -15.286988645951462], [166.99337261545477, -15.287412771388764], [166.99357549121726, -15.28785890164027], [166.99373371592137, -15.288322750451123], [166.99384576940247, -15.288799861333082], [166.99946530452345, -15.319395108103013], [167.01106170685372, -15.382531076345627], [167.01828694594172, -15.401948906394543], [167.01843687866733, -15.402422654500818], [167.01853904733633, -15.402908945209633], [167.01859244286112, -15.403402975581512], [167.01859653787096, -15.403899866234774], [167.0185512919208, -15.404394709537646], [167.01845715189052, -15.404882618079387], [167.0183150475714, -15.405358772941694], [167.0181263824829, -15.405818471293642], [167.01789302001038, -15.40625717284005], [167.01761726500112, -15.40667054466454], [167.01730184100015, -15.407054504024385], [167.0169498633505, -15.407405258674471], [167.01656480842408, -15.407719344322087], [167.01615047928655, -15.407993658842667], [167.01571096813572, -15.408225492918481], [166.96710866369403, -15.430850488986806], [166.96666356386658, -15.431032193987576], [166.96620307045123, -15.431170311249812], [166.9657314408121, -15.431263563848683], [166.96525303527014, -15.431311089643158], [166.96477227679108, -15.43131244924669], [166.96429361009407, -15.431267630089442], [166.9638214605592, -15.431177046534499], [166.963360193314, -15.431041536046983], [166.96291407287686, -15.43086235145151], [166.96248722373045, -15.430641149349544], [166.96208359219014, -15.430379974803742], [166.96170690991934, -15.430081242430903], [166.92125820356938, -15.394705714010595], [166.87240074882047, -15.372497780033815], [166.80147740704612, -15.3775402349157]]]}}, {"type": "Feature", "properties": {"title": "Fijian", "fill": "#CC5151", "family": "Austronesian", "cldf:languageReference": "fiji1243", "fill-opacity": 0.8}, "geometry": {"type": "MultiPolygon", "coordinates": [[[[181.5802179362901, -19.333916426066033], [181.57994322962642, -19.334322996988906], [181.57962999483124, -19.334700684200058], [181.57928124852683, -19.335045850365184], [181.57890034933072, -19.335355171345416], [181.57849096551047, -19.33562566821063], [181.578057039656, -19.335854735928145], [181.5776027507105, -19.336040168450616], [181.57713247372484, -19.336180179961488], [181.57665073772355, -19.336273422073372], [181.5761621820876, -19.33631899681376], [181.57567151187482, -19.336316465272986], [181.57518345250764, -19.336265851831175], [181.57470270426452, -19.33616764392344], [181.5742338970139, -19.33602278734561], [181.47908364215516, -19.301422694669693], [181.47863631407049, -19.301234988668263], [181.4782092817674, -19.301004816188513], [181.47780656508814, -19.30073434394489], [181.47743195498137, -19.300426118011178], [181.47708897781618, -19.3000830398532], [181.476780862187, -19.299708339016032], [181.4765105085213, -19.299305542722905], [181.47628046177664, -19.298878442671885], [181.47609288748384, -19.29843105934296], [181.47594955136196, -19.29796760415151], [181.47585180269675, -19.297492439804397], [181.47580056163923, -19.297010039231907], [181.47579631054393, -19.296524943482073], [181.4758390894283, -19.29604171897383], [181.49256600388782, -19.174558069852743], [181.49265771414136, -19.174071636790988], [181.4927970730856, -19.173596655761013], [181.4929827148474, -19.17313778210689], [181.4932128199303, -19.17269951330241], [181.49348513304787, -19.17228614487087], [181.4937969852276, -19.171901728284126], [181.49414531997022, -19.171550031253645], [181.4945267232066, -19.171234500802733], [181.49493745675946, -19.170958229481872], [181.4953734949817, -19.170723925058258], [181.4958305642122, -19.170533883976674], [181.49630418466256, -19.17038996885176], [181.4967897143239, -19.170293590212317], [181.49728239446378, -19.170245692676545], [181.49777739626714, -19.170246745693742], [181.498269868164, -19.170296738943158], [181.49875498338025, -19.170395182435172], [181.49922798724555, -19.170541111313725], [181.61862148233587, -19.213956927710207], [181.61907383372395, -19.21414703791009], [181.6195053728583, -19.214380570866883], [181.61991194378118, -19.214655277530547], [181.62028963099232, -19.214968512325743], [181.62063479715746, -19.21531725863016], [181.6209441181377, -19.215698157826246], [181.6212146150029, -19.216107541646515], [181.6214436827204, -19.216541467500992], [181.62162911524288, -19.21699575644649], [181.62176912675375, -19.21746603343212], [181.62186236886564, -19.217947769433433], [181.62190794360603, -19.218436325069394], [181.62190541206525, -19.218926995282157], [181.62185479862345, -19.219415054649343], [181.6217565907157, -19.21989580289245], [181.62161173413787, -19.220364610143083], [181.58064157944676, -19.3330325355436], [181.5804514692469, -19.333484886931675], [181.5802179362901, -19.333916426066033]]], [[[181.1632203996756, -18.08349349215859], [181.16276858329527, -18.083684870383244], [181.16230018418804, -18.083831041319886], [181.1618197132933, -18.08393059726249], [181.16133179780846, -18.083982579432906], [181.16084113662635, -18.083986487214418], [181.16035245508237, -18.083942282972952], [181.15987045944695, -18.08385039241952], [181.15939979160152, -18.08371170051038], [181.1589449843347, -18.083527542924436], [181.15851041768917, -18.083299693199912], [181.1581002767792, -18.083030345654212], [181.15771851148602, -18.082722094251437], [181.15736879841808, -18.082377907621105], [181.1570545055034, -18.082001100468617], [181.07336671672917, -17.97101948747728], [181.07309225568716, -17.970615956698577], [181.07285844147947, -17.970187591353092], [181.0726675015694, -17.969738472322454], [181.07252125497243, -17.96927287820114], [181.07242109492688, -17.96879524453585], [181.07236797562135, -17.968310121569672], [181.07236240310417, -17.96782213089354], [181.07240443046274, -17.96733592141804], [181.0724936573176, -17.966856125084888], [181.0726292336368, -17.96638731274012], [181.07280986783383, -17.965933950589292], [181.07303383907202, -17.965500357649546], [181.07329901365847, -17.965090664603917], [181.07360286537084, -17.964708774449782], [181.15729065414507, -17.869465259557824], [181.15764440803983, -17.869101648162342], [181.15803318576437, -17.868775754090798], [181.15845298516206, -17.868490932162786], [181.1588994847328, -17.86825011439294], [181.15936808811963, -17.86805577980817], [181.1598539714243, -17.867909928928064], [181.16035213286563, -17.867814063171135], [181.1608574442688, -17.867769169398905], [181.1613647038559, -17.86777570975696], [181.16186868979392, -17.867833616917526], [181.29211613898335, -17.88954152511577], [181.2925955984113, -17.889645843490577], [181.29306252412232, -17.889796654785926], [181.29351241936646, -17.889992506606607], [181.29394095140668, -17.89023151279252], [181.29434399324512, -17.890511371583443], [181.29471766336857, -17.89082938778623], [181.29505836312947, -17.891182498731006], [181.29536281140284, -17.891567303766337], [181.29562807618544, -17.891980097009384], [181.29585160283239, -17.89241690303556], [181.29603123865985, -17.892873515164045], [181.29616525367663, -17.893345535970436], [181.29625235724484, -17.893828419636336], [181.29629171050954, -17.89431751572807], [181.29628293447726, -17.894808113982904], [181.29622611366597, -17.895295489671458], [181.27977495157376, -17.994002462224618], [181.27967481342125, -17.994466315132136], [181.27953115261067, -17.9949185857822], [181.2793452631649, -17.99535520035292], [181.27911881948071, -17.99577222604431], [181.27885386124652, -17.996165906502977], [181.27855277507012, -17.996532695657397], [181.27821827298132, -17.996869289659106], [181.27785336800324, -17.99717265664209], [181.16405708090602, -18.082982903773978], [181.16365128209026, -18.08325874972284], [181.1632203996756, -18.08349349215859]]], [[[177.24666627194347, -17.923079589378222], [177.24665100889845, -17.922611719239526], [177.246679568509, -17.922144472221483], [177.2561552765168, -17.834646761039842], [177.2562335726257, -17.83415452169263], [177.25636048783755, -17.833672523368353], [177.2565347609713, -17.833205555777976], [177.25675466024097, -17.83275825926914], [177.25701800046477, -17.832335078714134], [177.25732216477977, -17.831940219340318], [177.25766413064608, -17.831577604941987], [177.2580404998825, -17.831250838888835], [177.28088290710906, -17.813335113180827], [177.28136204208155, -17.813002550278807], [177.2818766440552, -17.81272804487927], [177.37147715283325, -17.771453316582082], [177.4295562805626, -17.711260920919393], [177.4209410282388, -17.653090313528022], [177.38910972569587, -17.63258208626779], [177.3886999160695, -17.632287772248866], [177.38832185395455, -17.63195365593855], [177.3879793890013, -17.63158313950518], [177.38767600838892, -17.63117999576453], [177.38741480131682, -17.630748329762756], [177.38719842754875, -17.630292536976416], [177.38702909032935, -17.62981725855515], [177.3869085139496, -17.629327334062765], [177.38683792618892, -17.628827752197964], [177.38474747208735, -17.605634392822964], [177.38472733112124, -17.605164251885494], [177.3847514773851, -17.604694299635213], [177.38481969700274, -17.604228698686576], [177.38493138571712, -17.603771573112272], [177.38508555424252, -17.60332697191414], [177.38528083702712, -17.602898833159017], [177.38551550434852, -17.602490949097223], [177.38578747763475, -17.6021069325726], [177.38609434787523, -17.60175018502165], [177.51414610568773, -17.46633415413786], [177.51450764880616, -17.465988256963758], [177.5149019527553, -17.465680226645063], [177.5153250688448, -17.465413147899415], [177.62529516161823, -17.40346627900293], [177.6258690853625, -17.40318957694047], [177.8254082699328, -17.322218812780314], [177.82587530902853, -17.322055704695366], [177.82635618036673, -17.321939547386442], [177.82684617660624, -17.321871477939585], [177.82734050108047, -17.32185216269958], [177.82783431475295, -17.321881790746996], [177.8283227835875, -17.321960072047226], [177.8288011258697, -17.322086240289703], [177.82926465901568, -17.32225906038946], [177.8297088454112, -17.322476840577608], [177.83012933683096, -17.322737448962375], [177.83052201700437, -17.323038334398625], [177.8308830419103, -17.32337655146148], [177.8312088774072, -17.323748789279655], [177.83149633382928, -17.32415140394621], [177.83174259721082, -17.32458045418945], [177.84113292169872, -17.3429948386514], [177.90261644342806, -17.366199383797806], [177.90305711181043, -17.366390350554976], [177.90347742546788, -17.366622715257343], [177.90387350647023, -17.366894334043792], [177.90424170046435, -17.36720270088416], [177.90457861039053, -17.36754497070055], [177.9048811278244, -17.36791798561682], [177.90514646165636, -17.36831830409402], [177.9053721638429, -17.36874223268298], [177.9055561519932, -17.369185860101105], [177.9056967285816, -17.369645093318933], [177.90579259660953, -17.370115695323587], [177.90584287157202, -17.3705933242106], [177.9058470896183, -17.371073573243546], [177.87221671852456, -18.227187007081437], [177.87217346961194, -18.22767543802779], [177.87208258664955, -18.228157284004165], [177.87194494369612, -18.22862791090009], [177.8717618645204, -18.229082792503615], [177.87153510987, -18.229517554031705], [177.87126686053733, -18.22992801420436], [177.8709596963864, -18.230310225457686], [177.87061657154078, -18.230660511909228], [177.87024078597298, -18.23097550471046], [177.86983595376697, -18.231252174446368], [177.86940596836016, -18.231487860270576], [177.86895496509865, -18.23168029549581], [177.86848728146586, -18.231827629393553], [177.8680074153672, -18.23192844499325], [177.8675199818718, -18.231981772709922], [177.8670296688276, -18.231987099669034], [177.86654119177635, -18.23194437463903], [177.86605924860223, -18.23185400852406], [177.86558847435055, -18.231716870412125], [177.61523236323515, -18.145260082329322], [177.51911038975808, -18.12129352985649], [177.47720863476604, -18.130755575699396], [177.47668561666512, -18.130844820953122], [177.47615608632034, -18.13087814156517], [177.47562600651136, -18.130855162328587], [177.47510134620498, -18.130776142001203], [177.47458801334176, -18.13064197039189], [177.33306274478707, -18.08550456499638], [177.33261795293495, -18.085339064362802], [177.33219085579424, -18.085132138569783], [177.33178530117277, -18.08488565185526], [177.33140494279735, -18.084601824869814], [177.33105320739645, -18.084283214670386], [177.3307332638282, -18.083932691683174], [177.29836937222663, -18.044906431307197], [177.2980281272402, -18.044443060094643], [177.29774238488375, -18.043943548005597], [177.25776435754, -17.96366324405052], [177.25756840240294, -17.963216322505822], [177.25741694751056, -17.96275242736851], [177.2468273479012, -17.92400082519566], [177.24672522385708, -17.923543981560655], [177.24666627194347, -17.923079589378222]]], [[[181.06826503436733, -17.180884577213014], [181.06814580964397, -17.181360548989204], [181.06798050562787, -17.18182254276476], [181.06777071428704, -17.182266109287063], [181.06751845602682, -17.182686976768032], [181.0672261602321, -17.183081092023752], [181.06689664187124, -17.183444659508865], [181.06653307438611, -17.183774177869747], [181.0661389591304, -17.184066473664444], [181.06571809164944, -17.184318731924673], [181.06527452512714, -17.184528523265488], [181.06481253135158, -17.184693827281595], [181.0643365595754, -17.184813052004948], [181.06385119366695, -17.184885049236293], [181.0633611079653, -17.184909125602932], [180.9558899165494, -17.184909125602932], [180.95539075399338, -17.184884146883554], [180.9548965788139, -17.18480946029999], [180.95441232855623, -17.18468581208233], [180.9539428416009, -17.184514437660216], [180.9534928088211, -17.184297049319092], [180.95306672671379, -17.18403581909191], [180.95266885247312, -17.183733357057278], [180.95230316145472, -17.183392685260912], [180.95197330745592, -17.183017207520898], [180.9516825862089, -17.18261067541847], [180.95143390245144, -17.18217715081415], [180.95122974090427, -17.181720965263715], [180.95107214144497, -17.1812466767395], [180.9509626787266, -17.180759024089493], [180.92818642095304, -17.04871497349008], [180.9281273622071, -17.04823500273764], [180.9281149472456, -17.0477515715353], [180.92814929220296, -17.047269202089165], [180.92823007580296, -17.046792406673244], [180.92835654236387, -17.04632564541989], [180.9285275088677, -17.045873284597935], [180.92874137602627, -17.045439555768883], [180.92899614324187, -17.04502851620325], [180.92928942732152, -17.04464401092722], [180.92961848477026, -17.04428963675478], [180.92998023745494, -17.04396870864168], [180.93037130139834, -17.043684228676042], [180.93078801843407, -17.043438857995657], [180.93122649042667, -17.043234891894627], [180.9316826157362, -17.043074238352297], [180.93215212758668, -17.04295840018525], [180.93263063397904, -17.042888460989385], [180.93311365877585, -17.04286507500352], [181.0633611079653, -17.04286507500352], [181.06385119366695, -17.042889151370158], [181.0643365595754, -17.042961148601503], [181.06481253135158, -17.043080373324855], [181.06527452512714, -17.043245677340963], [181.06571809164944, -17.043455468681778], [181.0661389591304, -17.043707726942007], [181.06653307438611, -17.044000022736704], [181.06689664187124, -17.044329541097586], [181.0672261602321, -17.0446931085827], [181.06751845602682, -17.04508722383842], [181.06777071428704, -17.045508091319387], [181.06798050562787, -17.04595165784169], [181.06814580964397, -17.046413651617247], [181.06826503436733, -17.046889623393437], [181.06833703159867, -17.04737498930187], [181.0683611079653, -17.047865075003518], [181.0683611079653, -17.179909125602933], [181.06833703159867, -17.180399211304582], [181.06826503436733, -17.180884577213014]]]]}}, {"type": "Feature", "properties": {"title": "Samoan", "fill": "#CC5151", "family": "Austronesian", "cldf:languageReference": "samo1305", "fill-opacity": 0.8}, "geometry": {"type": "MultiPolygon", "coordinates": [[[[192.02004821623612, -14.612677885555852], [192.02048783428114, -14.61289824284613], [192.02090368007816, -14.613160718814544], [192.0212917312113, -14.61346277456926], [192.02164823411846, -14.61380148836893], [192.0219697403989, -14.614173583884273], [192.02225314016914, -14.614575461889535], [192.0224956921445, -14.61500323507727], [192.022695050155, -14.615452765659699], [192.02284928583964, -14.615919705392937], [192.0229569072991, -14.616399537636912], [192.02301687352664, -14.616887621044178], [192.02302860447767, -14.61737923445498], [192.02299198668047, -14.617869622564356], [192.02290737433358, -14.618354041919511], [192.02277558587997, -14.618827806802535], [192.02259789609013, -14.619286334554678], [192.0223760237316, -14.619725189903738], [192.0221121149433, -14.620140127865804], [192.0218087224766, -14.620527134806373], [192.02146878100268, -14.620882467263641], [192.0210955787259, -14.621202688158471], [192.02069272557753, -14.621484700040762], [192.02026411829746, -14.621725775050628], [192.01981390274156, -14.621923581304586], [191.75628958896908, -14.722553949475582], [191.75582989309157, -14.72270444585454], [191.75535780621493, -14.722809818720036], [191.75487774649562, -14.722869081910776], [191.75439420670617, -14.722881680795691], [191.7539117121883, -14.72284749746461], [191.75343477850132, -14.722766851831752], [191.7529678691619, -14.722640498641722], [191.75251535387105, -14.722469620406029], [191.75208146761912, -14.72225581633621], [191.75167027105138, -14.722001087377176], [191.7512856124654, -14.721707817480805], [191.75093109179565, -14.721378751295068], [191.7506100269225, -14.721016968477475], [191.75032542262093, -14.72062585487324], [191.75007994243956, -14.720209070827915], [191.749875883773, -14.71977051693102], [191.74971515636108, -14.719314297511287], [191.74959926441605, -14.718844682225168], [191.7495292925449, -14.718366066098055], [191.74950589559893, -14.717882928392218], [191.74950589559893, -14.558691601605119], [191.74953058348078, -14.55819534630098], [191.74960440332967, -14.557703991593767], [191.74972662616338, -14.557222389686258], [191.74989604501275, -14.556755296470849], [191.75011098684072, -14.556307324564385], [191.75036932906394, -14.555882897757861], [191.7506685205135, -14.55548620733082], [191.75100560662813, -14.555121170661815], [191.75137725863095, -14.55479139254371], [191.75177980640171, -14.554500129585787], [191.75220927471966, -14.55425025805424], [191.75266142251957, -14.554044245468614], [191.75313178477285, -14.553884126234651], [191.7536157165804, -14.553771481554246], [191.75410843904174, -14.553707423810824], [191.75460508644727, -14.55369258558438], [191.75510075432805, -14.55372711340467], [191.755590547888, -14.5538106663042], [191.88583799707746, -14.582754543901855], [192.01911486166048, -14.612371624920302], [192.01958907830445, -14.612501778427703], [192.02004821623612, -14.612677885555852]]], [[[190.38915023785418, -14.501060459018445], [190.38914955006038, -14.500560987018604], [190.38919869792585, -14.500063938490786], [190.38929719100847, -14.49957427343755], [190.38944404645466, -14.499096878182426], [190.3896377988071, -14.498636516609732], [190.38987651462847, -14.498197782626198], [190.3901578117951, -14.497785054318792], [190.39047888326783, -14.497402450266174], [190.39083652510334, -14.497053788439777], [190.39122716842587, -14.49674254810461], [190.3916469150409, -14.496471835099989], [190.39209157633465, -14.49624435084664], [190.3925567150721, -14.496062365389466], [190.39303768967557, -14.495927694744983], [190.39352970054279, -14.495841682779437], [190.39402783794156, -14.4958051877985], [190.39452713100357, -14.495818573982303], [190.58266233538833, -14.510290512781129], [190.58314913096243, -14.510352106087948], [190.58362754528295, -14.51046111711626], [190.58409297095852, -14.510616496030265], [190.58454092568542, -14.510816746446084], [190.58496709541478, -14.511059939842745], [190.5853673758991, -14.511343734134895], [190.58573791221852, -14.511665396228365], [190.58607513590573, -14.512021828341352], [190.5863757993123, -14.512409597837767], [190.58663700688524, -14.51282497028538], [190.5868562430528, -14.513263945420455], [190.5870313964509, -14.513722295672473], [190.58716078025654, -14.51419560687795], [190.58724314843295, -14.514679320791236], [190.58727770772956, -14.515168778982922], [190.58726412532144, -14.51565926770306], [190.57949449605584, -14.616664448155985], [190.579432902749, -14.617151243730065], [190.5793238917207, -14.617629658050603], [190.5791685128067, -14.618095083726166], [190.57896826239087, -14.618543038453067], [190.5787250689942, -14.618969208182412], [190.57844127470207, -14.61936948866674], [190.5781196126086, -14.619740024986168], [190.57776318049562, -14.620077248673386], [190.5773754109992, -14.62037791207994], [190.5769600385516, -14.620639119652868], [190.57652106341652, -14.62085835582045], [190.5760627131645, -14.621033509218545], [190.575589401959, -14.621162893024183], [190.57510568804574, -14.621245261200587], [190.57461622985406, -14.621279820497188], [190.5741257411339, -14.62126623808907], [190.42036054028546, -14.609438145716133], [190.41988642219582, -14.609378776377222], [190.41942013614974, -14.609274421192627], [190.41896594050792, -14.60912603318683], [190.41852798321534, -14.608934967514367], [190.41811026392014, -14.60870296908388], [190.41771659744686, -14.60843215662272], [190.41735057895735, -14.608125003327649], [190.4170155511182, -14.607784314278364], [190.41671457357353, -14.607413200820078], [190.41645039500295, -14.60701505214914], [190.4162254280192, -14.606593504361177], [190.41604172713485, -14.606152407244418], [190.4159009699996, -14.605695789121482], [190.38930059572888, -14.502046762242667], [190.38920075444386, -14.501557370304143], [190.38915023785418, -14.501060459018445]]], [[[189.26181452058646, -14.464596467623897], [189.2794536807427, -14.461956697116085], [189.2801358669544, -14.461901964194924], [189.37625097925908, -14.460789979941994], [189.376756574741, -14.460809733972473], [189.37725758492886, -14.46088048568444], [189.37774887913733, -14.461001510532217], [189.3782254261794, -14.461171569139003], [189.3786823458891, -14.461388919988936], [189.3791149590976, -14.461651337261399], [189.37951883555127, -14.461956133624945], [189.3798898392804, -14.462300187757386], [189.38022417095428, -14.46267997631027], [189.38051840678907, -14.463091609990363], [189.3807695336096, -14.463530873388654], [189.3809749797063, -14.46399326814901], [189.38701746017506, -14.479688840048425], [189.38716792584273, -14.480143525024499], [189.3872741983454, -14.480610520206264], [189.38733530261862, -14.48108554085046], [189.38735067802253, -14.481564228579124], [189.38732018348568, -14.482042191368304], [189.38724409879956, -14.482515043845465], [189.38712312205138, -14.482978447525868], [189.38695836321892, -14.483428150618753], [189.38675133398655, -14.483860027038073], [189.3865039338752, -14.484270114259909], [189.38621843281393, -14.48465464967913], [189.38589745031322, -14.485010105131828], [189.38554393143042, -14.485333219266662], [189.3851611197486, -14.485621027468223], [189.38475252761617, -14.485870889057752], [189.3680136360146, -14.495035699238416], [189.36752159271313, -14.495271177095086], [189.36700682583663, -14.495451652839646], [189.3664754622729, -14.49557497840336], [189.30909359654933, -14.50563061297621], [189.20347058864527, -14.59092784242019], [189.203078069195, -14.591214463351879], [189.20265957596305, -14.591461620168785], [189.2022190632598, -14.591666977505145], [189.20176069345587, -14.591828594955285], [189.20128879765232, -14.591944945408345], [189.20080783475632, -14.592014929477845], [189.20032234934925, -14.592037885889694], [189.19983692874538, -14.592013597730519], [189.1993561596467, -14.59194229449727], [189.1988845848034, -14.591824649928714], [189.19336090316278, -14.590157627223636], [189.192967664411, -14.59002084260618], [189.19258716915215, -14.589851815668991], [189.1922220556909, -14.58965171842287], [189.17519324709716, -14.579374923989276], [189.17490383563646, -14.579186328394174], [189.1181258815349, -14.539326556665658], [189.11773413519603, -14.539021411902285], [189.11737458834367, -14.538678914337925], [189.11705078723904, -14.538302442074285], [189.11676592557808, -14.53789570831032], [189.11652281299146, -14.53746272471842], [189.1163238473328, -14.53700776187673], [189.1161709910285, -14.536535307147822], [189.11606575172175, -14.536050020419228], [189.11600916740267, -14.53555668814229], [189.11600179617037, -14.535060176122727], [189.11604371072835, -14.534565381528513], [189.11613449766745, -14.534077184588407], [189.11627326154323, -14.533600400457582], [189.11645863370813, -14.533139731725063], [189.11668878581034, -14.532699722031433], [189.11696144782724, -14.532284711254263], [189.117273930455, -14.5318987927033], [189.13132727518158, -14.516205128152519], [189.13166205921232, -14.51586537266965], [189.13202769460386, -14.515559064171834], [189.14354808034605, -14.50680814864449], [189.14397195534266, -14.506519218163689], [189.14442320369346, -14.506275239145284], [189.14489707554316, -14.506078779720577], [189.26087913120722, -14.464830458187373], [189.26134117231274, -14.464690862410755], [189.26181452058646, -14.464596467623897]]], [[[188.15996735140976, -14.286582284285958], [188.15952767027886, -14.286446372231069], [188.1591023478774, -14.28627060978242], [188.15869498739357, -14.286056485940302], [188.1583090398483, -14.28580581468982], [188.01884370781704, -14.18580638689441], [188.01836953156905, -14.185420392917433], [188.0179460131708, -14.184979409209346], [188.01004196043644, -14.17567154788122], [188.00976142246137, -14.175308684025234], [188.00951531624426, -14.174921639501513], [188.0093057127368, -14.174513671239149], [188.00913437572507, -14.174088212237764], [188.00900274698768, -14.173648842679267], [188.00274664347205, -14.14864731680036], [188.00265351649492, -14.148182616556127], [188.00260480637138, -14.147711186524495], [188.00260095075012, -14.147237262390222], [188.002641984273, -14.146765102246984], [188.0027275382637, -14.146298948339423], [188.00285684404034, -14.145842988947603], [188.0030287398218, -14.145401320756333], [188.0080336226343, -14.134150824845689], [188.008279662848, -14.133669615076741], [188.00857620474866, -14.133217772704157], [188.00891978355693, -14.13280057702943], [188.00930638491687, -14.132422902543942], [188.0397324103075, -14.10575626130859], [188.04008542442844, -14.105474027751656], [188.04046248232834, -14.10522482484165], [188.0408605030709, -14.105010688813058], [188.04127623443256, -14.104833369369228], [188.04170627947656, -14.104694315385569], [188.1643259083828, -14.07108492512678], [188.1648602623754, -14.070969450721954], [188.16540402916524, -14.070913004235267], [188.18820066002462, -14.069801019982338], [188.18860213560373, -14.069797575243125], [188.25024764341623, -14.071744978197227], [188.2507182058749, -14.071782135512596], [188.2511831674733, -14.071863501387616], [188.25163838429336, -14.07198835065806], [188.32582661671523, -14.096154457835794], [188.32598860142002, -14.096210310491688], [188.45492536899815, -14.143154928716786], [188.45537423364203, -14.143343585476376], [188.45580262045556, -14.143575006260784], [188.63075989584618, -14.249405198826702], [188.63115610487188, -14.249671496922815], [188.63152511166078, -14.249974366957261], [188.6318635524021, -14.250311048012021], [188.6321683419206, -14.250678470952863], [188.64564185266278, -14.26859705768382], [188.6459406287582, -14.269042233080869], [188.64619002040752, -14.26951684038653], [188.6463871601226, -14.270015422598476], [188.64652978120452, -14.27053224705255], [188.6466162438058, -14.271061371336545], [188.64812686392298, -14.284950684080686], [188.6481560834886, -14.285460774098542], [188.64813309490552, -14.285971182889984], [188.6480581382165, -14.286476580856048], [188.6479319961061, -14.28697169071994], [188.63514513087173, -14.328222873276092], [188.63497731870822, -14.32868317299056], [188.63476526290145, -14.329124839249365], [188.63451099949881, -14.32954363140718], [188.6342169698028, -14.329935528443679], [188.63388599693067, -14.330296767571232], [188.63352125870853, -14.330623880363202], [188.63312625715946, -14.33091372605594], [188.632704784879, -14.331163521704726], [188.63226088862055, -14.331370868904143], [188.63179883044077, -14.33153377681628], [188.63132304677734, -14.331650681285707], [188.63083810585283, -14.331720459857674], [188.63034866381298, -14.331742442555319], [188.62985942002086, -14.331716418312428], [188.629375071936, -14.33164263699999], [188.60621330828687, -14.326943121226812], [188.5918298811261, -14.324770313570914], [188.5518750187368, -14.32203553171501], [188.52673018949628, -14.324495596725036], [188.52650247474207, -14.32451263605369], [188.4836863126327, -14.326734697210917], [188.48324041279952, -14.326737927926244], [188.42379217061202, -14.324515866769017], [188.42337994268618, -14.32448334760423], [188.3036594837018, -14.310037089059309], [188.30345355511147, -14.31000788302247], [188.1604176664396, -14.286677194545907], [188.15996735140976, -14.286582284285958]]], [[[187.6302159988518, -13.83946942634923], [187.63040336583902, -13.839840552874769], [187.64010795568277, -13.861229560443128], [187.64024439989737, -13.861561449891258], [187.6652535551708, -13.929199847108055], [187.66540446348452, -13.929681425699393], [187.66550605743578, -13.930175763567512], [187.66555730202086, -13.93067782457106], [187.66609135963805, -13.941093855454849], [187.66609066947802, -13.941619032758272], [187.66603489696197, -13.942141240669745], [187.66592465739836, -13.942654717947692], [187.66576116700153, -13.943153799670954], [187.6212207617281, -14.05829376091363], [187.62101337733475, -14.058758164392662], [187.62075988742865, -14.059199097205513], [187.62046291490918, -14.059611996951975], [187.62012553259706, -14.059992591294323], [187.61975123143944, -14.060336942163861], [187.61934388438846, -14.060641486508725], [187.6189077063272, -14.06090307316134], [187.61844721045776, -14.061118995444033], [187.61796716160228, -14.061287019175452], [187.6174725269008, -14.061405405787985], [187.60479247318986, -14.06376574972109], [187.6042637624484, -14.063835242322948], [187.6037306576817, -14.063848032067197], [187.60319922272762, -14.063803973475988], [187.569842266271, -14.059236975675669], [187.43574561330166, -14.046668733871678], [187.3437278258302, -14.061701942892048], [187.34331092264046, -14.061752186516497], [187.3428912737867, -14.06176727064647], [187.31997257261483, -14.061628034196275], [187.31947565478998, -14.061600244890574], [187.31898396137936, -14.061523191920996], [187.29997151020748, -14.05756544350791], [187.2995212240228, -14.05744962870213], [187.2990836423903, -14.05729248853469], [187.29866254900335, -14.0570953817697], [187.29826158498432, -14.056860012755594], [187.29788421740045, -14.056588416687914], [187.25137542833795, -14.019715552918383], [187.2510339146791, -14.019418663453415], [187.2507206418861, -14.019092113165206], [187.2504381759755, -14.0187385768263], [187.25018883062484, -14.018360950251912], [187.2348370005615, -13.992651892371887], [187.13429990709975, -13.879644420073223], [187.07396115272425, -13.827780593991102], [187.07346586572285, -13.82729090501552], [187.0523324428713, -13.803262126939348], [187.05199310930718, -13.80283068206881], [187.05170311318213, -13.8023646410926], [187.05146594943602, -13.801869620586382], [187.04426380099852, -13.784441222454058], [187.04410378638207, -13.78399521541487], [187.04398671028076, -13.783536063867999], [187.0439136241643, -13.78306789148942], [187.04388518442474, -13.782594902971905], [187.04390164648166, -13.782121346262345], [187.043962862488, -13.78165147441061], [187.04406828265806, -13.781189507372572], [187.044216960205, -13.780739594110353], [187.04440755984416, -13.780305775330172], [187.05189962527385, -13.76523581378232], [187.05214675469657, -13.764795912054788], [187.05243696111827, -13.764383157025426], [187.05276728923369, -13.764001751968255], [187.05313437515989, -13.763655580906136], [187.05353448069232, -13.763348169057977], [187.05396353137257, -13.763082646939809], [187.05441715798054, -13.762861718485308], [187.07136967262898, -13.755639542887163], [187.07183068959506, -13.75546938775502], [187.07230618312346, -13.755345309890473], [187.07279156014806, -13.755268507833136], [187.08946941659337, -13.753464156026496], [187.08992653779484, -13.75343579957477], [187.09038433597053, -13.753449390436906], [187.09083896993954, -13.75350481457802], [187.0912866250704, -13.753601606958794], [187.0917235452881, -13.753738955437413], [187.09214606458931, -13.75391570758388], [187.10158661537048, -13.758383486816872], [187.17341377214325, -13.764095822314165], [187.23134908955458, -13.754184250617884], [187.27568394882078, -13.742352764630494], [187.27586027731823, -13.742309123575808], [187.35252043356823, -13.72480729252112], [187.35272479619456, -13.724765102139163], [187.43689227666331, -13.70921258138721], [187.43720835476532, -13.70916457034497], [187.46748179226532, -13.705552052034424], [187.46794403125787, -13.70551852450583], [187.46840738892323, -13.705527940205258], [187.48088907837635, -13.706361451557797], [187.48130753495852, -13.706407154488366], [187.48172066430186, -13.70648789366525], [187.52665779809092, -13.717252015674527], [187.5271613306372, -13.717400984222106], [187.52764646305477, -13.717601939915626], [187.52810784459206, -13.717852666321072], [187.52854038645702, -13.718150398060038], [187.54416538645702, -13.730161926075175], [187.54458941654045, -13.730527422823927], [187.54496993117877, -13.730938029685776], [187.6102622895772, -13.809827876487534], [187.61055875040802, -13.810224538792257], [187.62999844767364, -13.839115148533468], [187.6302159988518, -13.83946942634923]]]]}}, {"type": "Feature", "properties": null, "geometry": {"type": "LineString", "coordinates": [[166.891, -15.3498], [178.33, -18.0], [188.17, -13.92]]}}]}
Loading

Now that we know how to simply display geographic data from CLDF datasets, let's see what we can do in terms of analysis.

Investigating GeoJSON data with shapely

Investigating geometric relations between the geographic objects in our data can be done using the shapely library. We could for example check whether Glottolog's point coordinate for a language (the point markers above) is contained in the speaker area reported by the Language Atlas:

>>> from shapely.geometry import shape
>>> for lg in lgs:
...     print('{}: {}'.format(
...         lg.cldf.name,
...         shape(lg.speaker_area_as_geojson_feature['geometry']).contains(shape({"type": "Point", "coordinates": [float(lg.cldf.longitude), float(lg.cldf.latitude)]}))))
... 
Ande: True
Fijian: False
Samoan: False

Note: While the Glottolog coordinate seems to be in the "true" speaker area in all cases, the areas from the digitized language atlas are slightly off, thus leading to the results above.

While shapely works well for geometric relations between objects, it will only do measurements in the cartesian plane, i.e. in a way that ignores that we are dealing with objects on the surface of the earth:

>>> from shapely.geometry import Point
>>> def make_point(lg):
...     return Point(float(lg.cldf.longitude), float(lg.cldf.latitude))
... 
>>> from shapely import distance
>>> distance(make_point(lgs[0]), make_point(lgs[1]))
11.741987950939164
>>> distance(make_point(lgs[1]), make_point(lgs[2]))
350.1837688985599

Investigating GeoJSON data with spatialite

A simple way to do geographically informed analysis on GeoJSON data is loading the data into a SQLite database with spatialite support.

On Ubuntu, mod_spatialite can be installed via

$ sudo apt install libsqlite3-mod-spatialite

Then we can use the geojson-to-sqlite tool to load the language areas of the Language Atlas into an SQLite database:

$ geojson-to-sqlite laop.sqlite features ../cldf-datasets/languageatlasofthepacificarea/cldf/languages.geojson --spatialite

With sqlite3, we can use the spatialite functionality after loading the extension:

$ sqlite3 laop.sqlite 
SQLite version 3.37.2 2022-01-06 13:25:41
Enter ".help" for usage hints.
sqlite> SELECT load_extension('mod_spatialite');

To make sure, spatialite does indeed compute things in a geographically informed way, let's compare the distances between Ande and Fijian and between Fijian and Samoan:

sqlite> select GeodesicLength(makeline(Centroid(l1.geometry), Centroid(l2.geometry)))
   ...> from features as l1, features as l2 where l1.title = 'Ande' and l2.title = 'Fijian';
1225051.19934628
sqlite> 
sqlite> select GeodesicLength(makeline(Centroid(l1.geometry), Centroid(l2.geometry)))
   ...> from features as l1, features as l2 where l1.title = 'Fijian' and l2.title = 'Samoan';
1166122.01078725

And indeed, both are about the same length, ~1,200,000 meters, or roughly 1,200km. Let's break this down.

  1. All GeoJSON features are stored as rows of the table features, with members of their properties object available as columns, e.g. title.
  2. The geometry column is equipped with the spatialite "magic", i.e. its values can be passed into the spatialite functions where a geographic data structure is expected.
  3. We want to compute proper great-circle distances, which is done in spatialite with the GeodesicLength function.
  4. The GeodesicLength function expects a line as argument, thus we make one using the makeline function.
  5. makeline expects two points, the start and the end of the line as arguments. The Glottolog coordinate is not available in the dataset's GeoJSON files, but we can instead compute the Centroids of the speaker areas!
  6. We select the two areas by joining the features table twice, using different aliases, and applying proper filter criteria for each join.

As could be expected from looking at spatialite's extensive function reference, we can do a lot more, e.g. computing areas:

sqlite> select title, Area(geometry, true) AS a from features where title in ('Samoan', 'Fijian', 'Ande') order by a desc;
Fijian|5497432116.0774
Samoan|3851329666.53359
Ande|183242601.080712

Note that we passed a second argument to Area, forcing true area computation on the ellipsoid, with results again using meter as unit. Thus the number ~5500000000 for Fijian means 5,500,000,000 m² or 5,500 km² - which is at least in the ballpark of the number given on Wikipedia for the Republic of Fiji.