I am working on an application that displays choropleth maps. These maps are of all different types, some display state by county, country by state/province, or world by country.

How should I handle storing the map information in the database?

My Thoughts:

I won't need to do queries to find POI inside a region, so I don't think there is a need to use spatial datatypes. I am considering storing a map as a geoJSON object (I am using JS mapping library that accepts geoJSON).

The only issue is what if I want a map of the US northeast. Then I would have geoJSON for the US and a separate one for the US northeast, which would be redundant.

Would it make sense to have a shape database where I had each state then when I needed a map of the US I could query for each state, and when I needed a map of the US Northeast I could again query for what I need?

Note: I am not concerned with storing the data for each region, just the region itself. I will query for the data on the fly for the specific region.


1 Answer 1


Having GeoJSON information for the US and a separate one for the US northeast is not redundant. One is telling you information pertaining to the entire US while the other is just telling you information pertaining to the US northeast. Without the latter, you'd have to accumulate information pertaining to all regions of the US in order to arrive at the same value.

This may not seem like much work, but when you consider that having GeoJSON information for the US northeast is redundant when you have New York, Maine, Massachusetts, etc., you quickly see a fractal pattern emerge. To be able to then calculate the accumulative value for the united states, you must potentially query and cycle through all counties of every state in the united states, which when done in runtime is no small order.

If it bothers you that modifying this information will render every parent region no longer accurate, you need only save the delta of the change in each parent region until you hit the country level. If you prefer, you can even decide to save calculated information in its own collection in case you wanted to clear it out and start from scratch.

If you must save lots of different types of information pertaining to a region, consider keeping region information in its own collection and region data information separate with a reference to the region itself, so you can avoid repeating it for each type of possible query you'd like to perform. You may also wish to cache region information since it isn't likely to change, whereas the data you're querying might.

I hope that helps!

  • Ok I have edited my question to include a note and revised the title. I dont need to store the data being visualized with a choropleth. I need to save the blank templates of the maps. I query based on some options(date,economic variable, etc) and get the information then shade the map accordingly. So when I say redundant I mean that a map of the US and a map of the US northeast both contain many of the same states. So would it be possible to save each state then when I want a map of the US by state I could query for each state and build that map.
    – Timigen
    Jun 5, 2014 at 15:33
  • @Timigen Ah, that is a completely different question. I think that unless you want to show a world map with county-level detail, you're likely not going to want to build a province using its counties, or build a country from its provinces. I see what you mean about redudancy now, though consider also that doing it this way, you can optimize the path (and not use every single point which makes up a region as you'd have to do when viewing with a higher resolution.
    – Neil
    Jun 5, 2014 at 15:43

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.