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