Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For convenience I'm trying to add an extra property to CountryData

CountryData[c_String, "MyProperty"] := 0; (* actually call to another function *)

But when using it I get:

CountryData["Greenland", "MyProperty"]

CountryData::notprop: "!(\"\\"MyProperty\\"\") is not a known property for CountryData. Use CountryData[\"Properties\"] for a list of properties."

What's the right way to do this?

There is high probability this is a duplicate, but I wasn't able to find how to do this, sorry in advance

share|improve this question
Tangentially related: – Mr.Wizard Jan 21 '13 at 19:54
up vote 18 down vote accepted

This is a matter of rules ordering for CountryData definitions. You have to do something like this:

CountryData[c_String, "MyProperty"] := 0;
(*actually call to another function*)
DownValues[CountryData] = RotateRight[DownValues[CountryData]];

This reorders the definitions so that yours is at the top (or close to the top). Then:


(* 0 *)
share|improve this answer
Perfect, thanks! – ssch Jan 21 '13 at 19:49
@ssch Was glad to help. I think I've run into exactly such problem with ...Data before. Also a good example of when manual rule reordering is really needed. Thanks for the accept. – Leonid Shifrin Jan 22 '13 at 10:14
@Leonid Shifrin from where do you know all that stuff!? Pretty impressing.manual rule reordering ... No shit Sherlock ;) – Stefan Jan 22 '13 at 20:06
@Stefan Long experience... :-). This particular issue is covered in Mathematica book and also David Wagner's book on Mathematica programming. – Leonid Shifrin Jan 23 '13 at 10:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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