Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

Here is what I have

  1. The population data aggregated by zip code given by US Census.

Here is what I am doing right now:

  1. Reverse geo code the center point to find the zip code of the center point.
  2. Associate a lat-long to each zip-code(by reverse geocoding, I know this will be error prone).
  3. Find the lat-longs(zip-codes) which are inside the circle, using Geokit-Rails plugin.
  4. Finding the sum of the data for those zip-codes(zip-code=zipcode of the center point or distance(between lat-long of the zip code and center point) < radius) and showing.

Am I doing this right? Is there methods efficient than this to find the population? Is there any algorithm already available?

I am using geokit-rails plugin for reverse geocoding and for finding the zip-codes(with associated lat-longs) within the circle.

The problem with this setup is that the zipcodes cannot be actually represented by the lat-long,it is an area.So, I am not sure the lat-long pair given by Google Map API is actually lies in the center of the zip code or something like that. Also,for radius 0 to almost 2.4 miles radius,the population remains same with this setup. That is, even for a radius of 0.1 miles, it will show the whole population of the zip code.I am looking for a way to approximate this.

I have asked same question in SO. Please have a look at this question also.

share|improve this question
Yopu haven't actually said what you are trying to achieve - this is quite important. You already have population by zip code, what is it you want? – Stev_k Oct 31 '11 at 13:38
@Stev_k..I want a way to approximate the transition from 0 miles to the boundary of the first zip code, likewise (now it will be the population for the zip code which the point it belongs, even if the radius selected is 0 or 0.2 or 0.4 or 1 or 2 miles etc.)..just rough approximation will be enough.. – rubyprince Oct 31 '11 at 13:44
Maybe I just haven't had enough coffee yet, but I'm having a hard time visualizing what you're talking about. A simple graphic illustration would be most helpful. – Kirk Kuykendall Oct 31 '11 at 13:53
I'm with other commentors - Not sure what you are trying to get but it seems that doing a radius to find crossing population would not be very accurate. i.e. If you cross by just .00001 percent of the poly you get 100% of the population. – Brad Nesom Oct 31 '11 at 14:28
Why not use Census 2010 Block TIGER data or 5-yr ACS data? Or Landscan? – MLowry Oct 31 '11 at 15:08

OK, so you have points representing the centroids of the zip codes, but not the full boundaries of the zip codes themselves, right?

I'm not sure how you would go about this in Ruby, and I think this may be more processing than you want to do, but a common way to do this in GIS software would be Voroni Polygons ( A possible methodology would be to build a polygon layer from all the points - which only has to be done once, then test which area each point is in. I'm still not 100% certain about what your input and output data are though, so I'm unsure whether this method would be more efficient.

It's a bit more difficult to find open source implementations for Voroni methodologies, but apparently there is a plugin for QGIS (Python)

share|improve this answer
thanks for your after building approximate polygon layer from the points, what should be the next step? How will I store the polygon boundary points? How to find how much of a single polygon is inside the circle ? I am very new to this. Please bear with me. – rubyprince Nov 1 '11 at 16:20
I am making a lot of assumptions here because the general agreement here is that you still haven't told us exactly what you want. But, assuming what you need is a polygon layer representing zip code boundaries, I would a) create voroni areas in a GIS b) load these into a PostGIS / Spatialite database. Assuming what you then want to work out the population around a certain point I would use Mersey Vikings instructions below. PHP / Python queries on the database might be more suitable than pure Ruby and while this is very doable there may be a few bumps along the way ... – Stev_k Nov 1 '11 at 17:40
Just found this ruby geolibrary although it doesn't appear to do some of the things you need, namely intersections, unions, or differences – Stev_k Nov 1 '11 at 18:00

As others have said, it is a little unclear, but if I understand you correctly, you have polygon data with a population count attribute. You want to specify a centre and radius of a circle to find the approximate population under that circle.

If that's the case, then the broad steps I'd use are:

  1. Calculate the population density of each polygon by dividing its population attribute by its area.
  2. Create a circle polygon representing your area of interest.
  3. Intersect a polygon with your circle.
  4. Find the area of each intersection and multiply it by the population density for that polygon.
  5. Rinse and repeat from step 3 for each polygon that is intersected by your circle.
  6. Sum up the results to get the approximate total population.

If, as @Stev_k says, you don't have the polygon dataset, then you'll have to find a way of deriving the polygons from the data you have.

share|improve this answer
How will I find the area shared between the zip code polygon and the circle? Where will I get the data for finding the polygon boundaries for each zip code? Sorry, if I sound like a noob but that is what I am I guess :( – rubyprince Nov 1 '11 at 15:59

Would something like David Martin's population surface software be what you are looking for?

share|improve this answer

To get an accurate population count, you should probably look into Apportionment techniques, like that described here, here, here, and here (Lecture 9, starting on slide 40).

Even if you choose not to use apportionment, if you at least use the 2010 Census Block centroids, you should be able to get a much better estimate of custom polygon population counts.

share|improve this answer

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.