0
$\begingroup$

I am trying to prime the following list into a database to run some geo-stats:

geostats = 
{{DateObject[{2013, 12, 5, 13, 47, 19.822}, "Instant","Gregorian", 10.], "VIC", -37.8004, 144.984, 100.},
{DateObject[{2013, 12, 5, 20, 44, 57.715}, "Instant", "Gregorian", 10.], "VIC", -36.9902, 144.063, 100.},
{DateObject[{2015, 3, 27, 15, 38, 46.051}, "Instant", "Gregorian", 10.], "NSW", -33.7495, 151.065, 60.},
{DateObject[{2015, 4, 29, 16, 05, 10.006}, "Instant", "Gregorian", 10.], "NSW", -33.8261, 151.199, 106.},
{DateObject[{2013, 6, 17, 20, 25, 34.948}, "Instant", "Gregorian", 10.], "SA", -34.9266, 138.512, 25.}, 
{DateObject[{2017, 7, 21, 20, 01, 42.497}, "Instant", "Gregorian", 10.], "VIC", -38.3296, 144.263, 10.},
{DateObject[{2016, 09, 25, 21, 27, 40.98}, "Instant", "Gregorian", 10.], "QLD", -27.4635, 152.98, 106.},
{DateObject[{2014, 10, 31, 15, 19, 59.965}, "Instant","Gregorian", 10.], "VIC", -37.9829, 145.065, 31.8}}

So I transform it as follows:

state[s_String] := Switch[s, "VIC", "Victoria", "NSW", "New South Wales", "SA",
    "South Australia", "QLD", "Queensland"];
geostats = geostats /. {s_, t_, u_, v_, w_} :> 
{s, Entity["AdministrativeDivision", {state[t], "Australia"}], GeoPosition[{u, v}], w}

The output shows that some States are successfully converted into Entities while others are not:

enter image description here

Can anyone help me convert all States into Entities? The geographic functions won't acknowledge "New South Wales" and "South Australia" :^(

Edit: I believe I found the solution: Composite Names should be written without spaces in between. The function state[s_String] should read

state[s_String] := Switch[s, "VIC", "Victoria", "NSW", "NewSouthWales",
    "SA", "SouthAustralia", "QLD", "Queensland"]
$\endgroup$
1
$\begingroup$

As you discovered, all Entity canonical names are camel cased, so you need to use camel case for your strings. However, you could also make use of Interpreter to find the appropriate canonical name:

Interpreter["AdministrativeDivision"]["New South Wales"]
Interpreter["AdministrativeDivision"]["South Australia"]

Entity["AdministrativeDivision", {"NewSouthWales", "Australia"}]

Entity["AdministrativeDivision", {"SouthAustralia", "Australia"}]

Another possibility is to use Control + =.

$\endgroup$
  • $\begingroup$ When I type Interpreter..., my output prints in interpreted format already. I don't get the "canonical" output as you do. $\endgroup$ – Thadeu Freitas Filho Jun 2 '19 at 3:39
  • $\begingroup$ @ThadeuFreitasFilho When I copy the output to MSE (Mathematica StackExchange) you see the InputForm, not the interpreted form. $\endgroup$ – Carl Woll Jun 2 '19 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.