You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-51Lines changed: 40 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,54 +2,72 @@
2
2
3
3
Zipcode data is free from the various governments around the world. Yet so many organizations, reputable or not, want to charge money for it.
4
4
5
-
We originally pulled down all the US census data we could find, parsed it and exported it into .csv files.
5
+
This project is an automated solution for retrieving and collating US and worldwide zipcode data.
6
6
7
-
In 2017 we began using [GeoNames](http://www.geonames.org) data, which is licensed under Creative Commons:
7
+
## History
8
8
9
-
We thank [GeoNames](http://www.geonames.org) for sharing, and urge you to [visit their site](http://www.geonames.org) and support their work.
9
+
In 2011, we originally pulled down all the US census data we could find, parsed it and exported it into 3 .csv files. Later, we wrote 3 rake tasks to automate this process.
10
+
11
+
In 2017 we began using [GeoNames](http://www.geonames.org) data, which is licensed under Creative Commons. We are grateful to [GeoNames](http://www.geonames.org) for sharing, and urge you to [visit their site](http://www.geonames.org) and support their work.
12
+
13
+
In 2018 we refactored the project and made it into a Ruby gem with a command-line executable for automating this process.
10
14
11
15
## What's Included
12
16
13
-
There are three rake tasks which automatically download the latest zipcode data from the country that you specify. Not all countries are accounted for. Please check [GeoNames](http://download.geonames.org/export/zip/) to see a list of supported country zip files.
17
+
* An executable: `free_zipcode_data` - which automates the process of downloading and process the zipcode data from GeoNames. Not all countries are accounted for. Please check [GeoNames](http://download.geonames.org/export/zip/) to see a list of supported country zip files.
14
18
15
-
Each zipcode is correlated with estimated or zip-centroid, latitude and longitude coordinates. Where applicable, county/province, state and community are also correlated.
19
+
Each zipcode is correlated with estimated or zip-centroid, latitude and longitude coordinates. Where applicable, country, county/province, state and community are also correlated.
16
20
17
21
See the GeoNames [readme.txt](http://download.geonames.org/export/zip/readme.txt) file for more information.
18
22
19
23
## Usage
20
24
25
+
First, you need to install Ruby and Rubygems. Though that is not a difficult task, it is beyond the scope of this README. A search engine of your choice will help discover how to do this. Once you have done that:
Determine the countries you want to use at [GeoNames](http://download.geonames.org/export/zip/), or just use the rake task without any `country` argument to get zipcode data for all countries...
31
+
Determine the 2-letter country codes for the countries you want to use at [GeoNames](http://download.geonames.org/export/zip/), or don't specify a country to get all zipcodes for all available countries...
32
+
33
+
### Command Line Options
34
+
28
35
```bash
29
-
# download will pull down the zipcodes for the specified country
30
-
$ rake data:download[country]
31
-
# rake data:download[US] - For US-only zipcodes
32
-
# rake data:download[GB_full.csv] - All UK data zipcodes:
33
-
# rake data:download - ALL zipcodes
36
+
Options:
37
+
-w, --work-dir=<s> REQUIRED: Specify your work/build directory, where the SQLite and .csv files will be built
38
+
-f, --country=<s> Specify the country code for processing, or all countries if not specified
The rake tasks cascade, from the bottom up. So if you run `rake data:populate_db`, it will automatically call `rake data:build`if the .csv files are missing, which will call `rake data:download`if the .zip files are missing.
49
65
50
66
## SQLite3 Database
51
67
52
-
The rake task `rake data:populate_db[country]` will create an SQLite3 database with the following tables, and populate each one:
68
+
The executable will generate an SQLite3 database in the specified directory `--work-dir` but it will not generate the `.csv` files by default. Specify `--generate-files`if you want those as well.
69
+
70
+
By default the tables will be named as follows. To override the table names see the command line options above.
53
71
54
72
```sql
55
73
create table countries (
@@ -79,7 +97,6 @@ create table zipcodes (
79
97
id integer not null primary key,
80
98
code varchar(10) not null,
81
99
state_id integer,
82
-
county_id integer,
83
100
city varchar(255),
84
101
area_code varchar(3),
85
102
lat float,
@@ -95,32 +112,4 @@ Both `lat` and `lon`, geocodes, are populated for each zipcode record.
95
112
The zipcode data is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>, carried forward from [GeoNames](http://www.geonames.org).<br />
0 commit comments