4
$\begingroup$

I like to use Mathematica to answer questions related to cities such as how many cities in the United States have a population greater than 100,000 and what the distribution of them would look like on a map of the continental US.

I have run into an issue downloading the values of all 175,000 cities every time I query CityData or Entity of type City. It often takes 10 to 30 minutes for one line of code to run, such as:

citiespopulationbiggerthanhundredthousand = 
 EntityList[
  FilteredEntityClass["City", 
   EntityFunction[c, c["Population"] >= Quantity[100000, "People"]]]]

I am wondering if there is a way to reduce the wait time using EntityPrefetch, caching, or preloading the data. I have preloaded the data for CityData but when I ran the above code it had to re-download all. I have also tried using EntityPrefetch for CityData. I have found that running RebuildPacletData[] caches the data for offline use. I also would like to extend this to other types of entities, such as "Aircraft" or "Countries".

$\endgroup$
3
  • $\begingroup$ This Wolfram support article discusses how to pre-download some material in paclets, which should include CityData: support.wolfram.com/12436. $\endgroup$
    – MarcoB
    Commented Nov 22, 2021 at 14:03
  • 1
    $\begingroup$ Also see: How to keep downloaded curated data and Make it fast to answer lots of similar Entity questions. $\endgroup$
    – MarcoB
    Commented Nov 22, 2021 at 14:04
  • 1
    $\begingroup$ I do not have any experience with FilteredEntityClass, not sure how your expression is different from EntityList@ EntityClass["City", {"Population" -> GreaterThan[Quantity[100000, "People"]]}] which is much faster for me $\endgroup$
    – Jason B.
    Commented Nov 22, 2021 at 17:02

0

Your Answer

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