Message Boards Message Boards

0
|
8837 Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How do I make a map of several zipcodes or countries?

Posted 6 years ago

Hey, Community.

I have a list of zipcodes, and for each zipcode I have certain data, say for example the number of people from that zipcode who took a test (this is known data). Picture a spreadsheet with column 1, zipcodes, column 2 , number of people who took the test.

How do I make a map showing those zipcodes? Could I label each zipcode with the number of people who took the test? How?

Thank you.

POSTED BY: Jorge Mahecha
4 Replies
Posted 4 years ago

How to:

(*https://download.geonames.org/export/zip/allCountries.zip*)

allCountries = 
  Import["/Users/admin/Documents/allCountries.csv", {"TSV", 
    "RawData"}];

zipToCoordinatesMexico = 
  Association[
   Map [#[[2]] ->  Map[ToExpression, #[[10 ;; 11]]] &,  
    Select[allCountries, #[[1]] == "MX" &] ]];
POSTED BY: Valery Syssik

I have a dataset of over a 1000 zipcodes so it takes a lot of time. I'm getting this weird message: enter image description here

It's really strange, for three reasons at least:

  1. The first, I've never sene a "Try again" message. What does that mean?
  2. The second reason is that 06883 is a valid zipcode that for example, Wolfram Alpha recognizes.
  3. The line I'm running is something like zips = Interpreter["ZIPCode"] /@ {"95014", "01545", "94087", "95129", "01810", "10471", "02067", "01720"...} It does not always interpret the same ZIP codes the right way. For example, the first time I ran it, there was no issue with code 94568, but the second time it showed the aforementioned error.

What could be the issue? I'd appreciate any suggestions.

POSTED BY: Jorge Mahecha

Thank you, Marco, This definitely helps!

POSTED BY: Jorge Mahecha

Dear Jorge,

I am not sure whether this helps, because I do not have your data, but here's an idea. Suppose we look at US zip codes in the range from 85001 to 85055. We can generate the Entities for these codes:

zipcodes = Cases[Interpreter["ZIPCode"][ToString /@ Range[85001, 85055]], _Entity]

enter image description here

Let's generate a list of fake numbers of people who did the test:

teststaken = RandomInteger[{1, 500}, Length[zipcodes]]

Then this should work:

GeoRegionValuePlot[Rule @@@ Transpose[{zipcodes, teststaken}]]

enter image description here

Hope this goes in the right direction.

Cheers,

Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract