8 Comments

Ngl when I read the title I thought you were going to discuss the tree data structure 🤣

I liked the journey, it was fun to read. I was thinking though that if individual trees can’t be told apart from one another, chances are you aren’t interested to identify specific trees. In that case, grouping them by species for example would be more useful to use as a key. But as you said, it depends on what you want to do with the data.

Expand full comment
author

Indeed, it very much depends on what the data is needed for!

Expand full comment

Yes true. In grid it feels intuitive. Trees seem to be something concrete, they might deserve a name or number and they can be used as key. That only feels natural.

Expand full comment

I'm not sure how the geographical coordinates can be the key when they are yet another property of a tree. Seems suited to the purpose, but thinking generally, it seems somewhat counterintuitive.

Expand full comment
author

The key in a dictionary is how you want to be able to access the value. Often, it's a label, like an attribute name, but it's whatever you want to use to be able to access a value.

Expand full comment
author

The main point is that the right data structure depends on how the data is meant to be used. You need a way to access each tree, and as they're not a sequence (we _could_ make them a sequence, but I don't think that makes much sense, either), then their geographic location is a good way of identifying each tree.

And they're unique, too!

Expand full comment

Yes, makes sense. Just that it felt somewhat counterintuitive.

Expand full comment
author

You're correct that it's not the most common use for a key in a dictionary. A similar and more common use is to refer to positions in a grid, for example (assuming you're not using NumPy or other packages). A dictionary can represent a grid with a tuple with the coordinates as keys, such as `(0, 0)`

Expand full comment