]> gitweb.michael.orlitzky.com - dead/census-tools.git/blob - bin/find_avg_population_density
Initial commit.
[dead/census-tools.git] / bin / find_avg_population_density
1 #!/usr/bin/python
2
3 # Basically, add '../src' to our path.
4 import sys, os, site
5 site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
6
7 import ExitCodes, GPS, SummaryFile1
8
9 # Find the average population density of a set of GPS coordinates
10 # given a (SF1) geographic header file.
11
12 if (len(sys.argv) < 4):
13 print "Usage: %s <latitude> <longitude> <geo_file>" % sys.argv[0]
14 raise SystemExit(ExitCodes.NotEnoughArgs)
15
16 # If we made it here, it's sort of safe to parse the arguments
17 # and hope they're in order.
18
19 coords = GPS.Coordinates()
20 coords.latitude = float(sys.argv[1])
21 coords.longitude = float(sys.argv[2])
22 geo_file_path = sys.argv[3]
23
24 avg_density = SummaryFile1.FindAveragePopulationDensity(coords, geo_file_path)
25
26 print str(avg_density)
27