1
$\begingroup$

I am working on computing the 20 largest cities in California.

enter image description here

EntityList[
 EntityClass["City", 
  List[Rule[EntityProperty["City", "AdministrativeDivision"], 
    Entity["AdministrativeDivision", 
     List["California", "UnitedStates"]]], 
   Rule[EntityProperty["City", "Population"], TakeLargest[20]]]]]

I do not understand what I am doing wrong here. Can someone help me figure this out?

$\endgroup$
2
  • $\begingroup$ No specific answer here. Tried a few things. But here's an alternate solution (suggested by W|A queried for "cities in California"): GeoEntities[Entity["AdministrativeDivision", {"California", "UnitedStates"}], "City"] $\endgroup$
    – b3m2a1
    Commented Dec 6, 2021 at 4:16
  • $\begingroup$ I don't think you're doing anything wrong here, I think this might be a bug. $\endgroup$
    – Greg Hurst
    Commented Dec 6, 2021 at 13:39

1 Answer 1

1
$\begingroup$
citiesCalifornia = 
  GeoEntities[
   Entity["AdministrativeDivision", {"California", "UnitedStates"}], 
   "City"];

abc = EntityList[
   SortedEntityClass[citiesCalifornia, 
    "Population" -> "Descending"]][[1 ;; 20]]

enter image description here

EDIT

After the comment by OP: I ran the same procedure on cities in Texas which on my machine [Win7/x64/8Gb/rot HD/ (old machine) Mma 12.2.0] took 85.4s for the first time the entities were being read. The second time around it took a few seconds.

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ GeoEntities takes a long to run. Absolute Timing for Texas which I'm also interested in returned 124.7 seconds. That is too long for one state if I am going to run my program over all 50 states. Maybe I could select only the cities in the UnitedStates and run the program on those? $\endgroup$ Commented Dec 6, 2021 at 13:12
  • $\begingroup$ If it runs slowly the first time, we can conclude or surmise that it is busy retrieving data. If it runs slowly the second time, then I wouldn't know how to explain it. $\endgroup$
    – Syed
    Commented Dec 6, 2021 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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