From c54af7c770219648376a6e5ddd4a2a97756163c0 Mon Sep 17 00:00:00 2001 From: Carla Date: Mon, 25 Aug 2014 12:33:47 +0200 Subject: [PATCH 1/6] add data sources --- geocoder/ip-addresses/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/geocoder/ip-addresses/README.md b/geocoder/ip-addresses/README.md index 5702d3c..f7ee266 100644 --- a/geocoder/ip-addresses/README.md +++ b/geocoder/ip-addresses/README.md @@ -5,11 +5,14 @@ IP address geocoder ### Creation steps -1. upload a new dataset to the geocoder table, call it latest_ip_address_locations +1. Upload a new dataset to the geocoder table, call it latest_ip_address_locations 2. Run the sql/build_data_table script to update the table ### Data Sources +GeoLite2 open source database [Created by MaxMind](http://www.maxmind.com) - +http://dev.maxmind.com/geoip/geoip2/geolite2/ Download the CSV [Geolite2 City](http://geolite.maxmind.com/download/geoip/database/GeoLite2-City-CSV.zip) + ### Preparation details From 8cd501a4be1b16e2184cb466985a7c0e3b22da0b Mon Sep 17 00:00:00 2001 From: Carla Date: Mon, 25 Aug 2014 12:38:52 +0200 Subject: [PATCH 2/6] modifies comment in sql for title --- geocoder/ip-addresses/sql/build_data_table.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geocoder/ip-addresses/sql/build_data_table.sql b/geocoder/ip-addresses/sql/build_data_table.sql index dbf5dc3..93fc454 100644 --- a/geocoder/ip-addresses/sql/build_data_table.sql +++ b/geocoder/ip-addresses/sql/build_data_table.sql @@ -1,5 +1,5 @@ ----- Postal Code Polygon table --- +---- IP addresses table --- --- --- -- Clear table From ec78d147bf447b1cf9872da92656b3c0f9967320 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 26 Aug 2014 11:00:13 +0200 Subject: [PATCH 3/6] solves #50 --- geocoder/postal-codes/README.md | 36 ++++++++++++++++++- .../sql/build_zipcode_points_table.sql | 26 ++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 geocoder/postal-codes/sql/build_zipcode_points_table.sql diff --git a/geocoder/postal-codes/README.md b/geocoder/postal-codes/README.md index dd49dc9..7c4b55f 100644 --- a/geocoder/postal-codes/README.md +++ b/geocoder/postal-codes/README.md @@ -17,9 +17,43 @@ USA polygons - http://www2.census.gov/geo/tiger/TIGER2013/ZCTA5/tl_2013_us_zcta5 French polygons - http://www.data.gouv.fr/dataset/fond-de-carte-des-codes-postaux +All countries points [GeoNames](www.geonames.org) - http://download.geonames.org/export/zip/allCountries.zip + ### Preparation details # Postal code geocoder (points) -todo +1. Download the allCountries.zip file from [GeoNames](www.geonames.org). Import and rename the table as tmp_zipcode_points. You can follow the manual process explained below instead. + +This dataset includes data for the following countries: + +```` +CH, ES, GU, ZA, MX, SJ, NL, RU, AX, TH, AR, MY, RE, LK, GB, IS, GL, JE, DK, IN, +SI, GP, MQ, BR, SM, BG, NZ, MP, CZ, DO, MD, PK, TR, VI, BD, GG, LT, PM, MC, US, +IT, LU, SK, LI, PR, IM, NO, PT, PL, FI, JP, CA, DE, HU, PH, SE, VA, YT, MK, FR, +MH, RO, FO, GF, AD, HR, DZ, GT, AU, AS, BE, AT +```` + +The columns that are loaded are the following ones: +field_1: corresponding to ISO2 +field_10: corresponds to latitude +field_11: corresponds to longitude +field_2: corresponds to ZIP code + +2. Georeference the table using field11 as longitude and field10 as latitude in order to construct the_geom. + +3. Add column iso3 (text) and run sql/build_zipcode_points_table.sql. + + +**Alternative manual process** + +Open the allCountries.txt file with Excel an add a new row on top. Delete columns C-I and L. + +In the first row, add the following columns: iso2, zipcode, lat, long. + +Import the file ignoring step 2. + +_The big size of the dataset may cause interruptions in the processing of the coordinates after uploading the file, manipulating the file before importing is a faster workaround._ + + diff --git a/geocoder/postal-codes/sql/build_zipcode_points_table.sql b/geocoder/postal-codes/sql/build_zipcode_points_table.sql new file mode 100644 index 0000000..30ea6db --- /dev/null +++ b/geocoder/postal-codes/sql/build_zipcode_points_table.sql @@ -0,0 +1,26 @@ + +---- Postal Code Points table --- + +-- Clear table + +DELETE FROM zipcode_points; + +-- Insert points + +DELETE FROM zipcode_points; + +INSERT INTO zip_code_points (the_geom, zipcode, iso3) +SELECT the_geom, zipcode, + ( + SELECT country_decoder.iso3 FROM country_decoder + WHERE tmp_zipcode_points.iso2 = country_decoder.iso2 + ) +FROM tmp_zipcode_points +); + + +-- Drops temporary table + +DROP TABLE tmp_zipcode_points; + + From 5e5fc1777cbac63e76bdbf72889123d48b4f6706 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 26 Aug 2014 11:09:14 +0200 Subject: [PATCH 4/6] fixes markdown --- geocoder/postal-codes/README.md | 39 ++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/geocoder/postal-codes/README.md b/geocoder/postal-codes/README.md index 7c4b55f..dc686d9 100644 --- a/geocoder/postal-codes/README.md +++ b/geocoder/postal-codes/README.md @@ -24,35 +24,38 @@ All countries points [GeoNames](www.geonames.org) - http://download.geonames.org # Postal code geocoder (points) -1. Download the allCountries.zip file from [GeoNames](www.geonames.org). Import and rename the table as tmp_zipcode_points. You can follow the manual process explained below instead. +Download the allCountries.zip file from [GeoNames](www.geonames.org). Import and rename the table as tmp_zipcode_points. You can follow the manual process explained below instead. -This dataset includes data for the following countries: + This dataset includes data for the following countries: + + ```` + CH, ES, GU, ZA, MX, SJ, NL, RU, AX, TH, AR, MY, RE, LK, GB, IS, GL, JE, DK, IN, + SI, GP, MQ, BR, SM, BG, NZ, MP, CZ, DO, MD, PK, TR, VI, BD, GG, LT, PM, MC, US, + IT, LU, SK, LI, PR, IM, NO, PT, PL, FI, JP, CA, DE, HU, PH, SE, VA, YT, MK, FR, + MH, RO, FO, GF, AD, HR, DZ, GT, AU, AS, BE, AT + ```` -```` -CH, ES, GU, ZA, MX, SJ, NL, RU, AX, TH, AR, MY, RE, LK, GB, IS, GL, JE, DK, IN, -SI, GP, MQ, BR, SM, BG, NZ, MP, CZ, DO, MD, PK, TR, VI, BD, GG, LT, PM, MC, US, -IT, LU, SK, LI, PR, IM, NO, PT, PL, FI, JP, CA, DE, HU, PH, SE, VA, YT, MK, FR, -MH, RO, FO, GF, AD, HR, DZ, GT, AU, AS, BE, AT -```` + The columns that are loaded are the following ones: -The columns that are loaded are the following ones: -field_1: corresponding to ISO2 -field_10: corresponds to latitude -field_11: corresponds to longitude -field_2: corresponds to ZIP code + - field_1: corresponding to ISO2 + - field_10: corresponds to latitude + - field_11: corresponds to longitude + - field_2: corresponds to ZIP code -2. Georeference the table using field11 as longitude and field10 as latitude in order to construct the_geom. +1. Georeference the table using field11 as longitude and field10 as latitude in order to construct the_geom. -3. Add column iso3 (text) and run sql/build_zipcode_points_table.sql. +2. Add column iso3 (text) and run sql/build_zipcode_points_table.sql. **Alternative manual process** -Open the allCountries.txt file with Excel an add a new row on top. Delete columns C-I and L. +1. Open the allCountries.txt file with Excel an add a new row on top. -In the first row, add the following columns: iso2, zipcode, lat, long. +2. Delete columns C-I and L. -Import the file ignoring step 2. +3. In the first row, add the following columns: iso2, zipcode, lat, long. + +4. Import the file ignoring step 1. _The big size of the dataset may cause interruptions in the processing of the coordinates after uploading the file, manipulating the file before importing is a faster workaround._ From a4d7962682e4e1d5a817b05dcad816142eca4354 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 26 Aug 2014 11:19:53 +0200 Subject: [PATCH 5/6] adds info for polygons and reorganizes document --- geocoder/postal-codes/README.md | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/geocoder/postal-codes/README.md b/geocoder/postal-codes/README.md index 7c4b55f..9b3c89e 100644 --- a/geocoder/postal-codes/README.md +++ b/geocoder/postal-codes/README.md @@ -3,8 +3,14 @@ Postal code geocoder (polygons) ### Function +By following the next steps a table is populated with zipcodes from Australia, Canada, USA and France (identified by iso3) related with their spatial location in terms of polygons. + ### Creation steps +1. Import the four files attached in the section "Datasources". + +2. Run sql/build_data_table.sql. Notice that table "postal_code_polygons" should exist in advance with columns: _the_geom_, _adm0_a3_ and _postal_code_. + ### Data Sources Australian polygons - http://www.abs.gov.au/AUSSTATS/abs@.nsf/DetailsPage/2033.0.55.0012011?OpenDocument @@ -17,14 +23,21 @@ USA polygons - http://www2.census.gov/geo/tiger/TIGER2013/ZCTA5/tl_2013_us_zcta5 French polygons - http://www.data.gouv.fr/dataset/fond-de-carte-des-codes-postaux -All countries points [GeoNames](www.geonames.org) - http://download.geonames.org/export/zip/allCountries.zip - ### Preparation details +The names of the imported files are: + +- doc for Australia table +- gfsa000a11a_e for Canada table +- tl_2013_us_zcta510 for USA table +- codes_postaux for France table + # Postal code geocoder (points) -1. Download the allCountries.zip file from [GeoNames](www.geonames.org). Import and rename the table as tmp_zipcode_points. You can follow the manual process explained below instead. +### Function + +By following the next steps a table is populated with zipcodes of different countries (identified by iso3) related with their spatial location in terms of points. This dataset includes data for the following countries: @@ -35,6 +48,11 @@ IT, LU, SK, LI, PR, IM, NO, PT, PL, FI, JP, CA, DE, HU, PH, SE, VA, YT, MK, FR, MH, RO, FO, GF, AD, HR, DZ, GT, AU, AS, BE, AT ```` +### Creation steps + +1. Download the allCountries.zip file from [GeoNames](www.geonames.org). Import and rename the table as tmp_zipcode_points. You can follow the manual process explained below instead. + + The columns that are loaded are the following ones: field_1: corresponding to ISO2 field_10: corresponds to latitude @@ -54,6 +72,12 @@ In the first row, add the following columns: iso2, zipcode, lat, long. Import the file ignoring step 2. +### Data Sources + +All countries points [GeoNames](www.geonames.org) - http://download.geonames.org/export/zip/allCountries.zip + +### Preparation details + _The big size of the dataset may cause interruptions in the processing of the coordinates after uploading the file, manipulating the file before importing is a faster workaround._ From 8482759057651d0eca654721b10c333bc028c070 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 26 Aug 2014 11:24:43 +0200 Subject: [PATCH 6/6] postal-codes --- geocoder/postal-codes/README.md | 65 ++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/geocoder/postal-codes/README.md b/geocoder/postal-codes/README.md index dc686d9..9b3c89e 100644 --- a/geocoder/postal-codes/README.md +++ b/geocoder/postal-codes/README.md @@ -3,8 +3,14 @@ Postal code geocoder (polygons) ### Function +By following the next steps a table is populated with zipcodes from Australia, Canada, USA and France (identified by iso3) related with their spatial location in terms of polygons. + ### Creation steps +1. Import the four files attached in the section "Datasources". + +2. Run sql/build_data_table.sql. Notice that table "postal_code_polygons" should exist in advance with columns: _the_geom_, _adm0_a3_ and _postal_code_. + ### Data Sources Australian polygons - http://www.abs.gov.au/AUSSTATS/abs@.nsf/DetailsPage/2033.0.55.0012011?OpenDocument @@ -17,45 +23,60 @@ USA polygons - http://www2.census.gov/geo/tiger/TIGER2013/ZCTA5/tl_2013_us_zcta5 French polygons - http://www.data.gouv.fr/dataset/fond-de-carte-des-codes-postaux -All countries points [GeoNames](www.geonames.org) - http://download.geonames.org/export/zip/allCountries.zip - ### Preparation details +The names of the imported files are: + +- doc for Australia table +- gfsa000a11a_e for Canada table +- tl_2013_us_zcta510 for USA table +- codes_postaux for France table + # Postal code geocoder (points) -Download the allCountries.zip file from [GeoNames](www.geonames.org). Import and rename the table as tmp_zipcode_points. You can follow the manual process explained below instead. +### Function - This dataset includes data for the following countries: - - ```` - CH, ES, GU, ZA, MX, SJ, NL, RU, AX, TH, AR, MY, RE, LK, GB, IS, GL, JE, DK, IN, - SI, GP, MQ, BR, SM, BG, NZ, MP, CZ, DO, MD, PK, TR, VI, BD, GG, LT, PM, MC, US, - IT, LU, SK, LI, PR, IM, NO, PT, PL, FI, JP, CA, DE, HU, PH, SE, VA, YT, MK, FR, - MH, RO, FO, GF, AD, HR, DZ, GT, AU, AS, BE, AT - ```` +By following the next steps a table is populated with zipcodes of different countries (identified by iso3) related with their spatial location in terms of points. - The columns that are loaded are the following ones: +This dataset includes data for the following countries: - - field_1: corresponding to ISO2 - - field_10: corresponds to latitude - - field_11: corresponds to longitude - - field_2: corresponds to ZIP code +```` +CH, ES, GU, ZA, MX, SJ, NL, RU, AX, TH, AR, MY, RE, LK, GB, IS, GL, JE, DK, IN, +SI, GP, MQ, BR, SM, BG, NZ, MP, CZ, DO, MD, PK, TR, VI, BD, GG, LT, PM, MC, US, +IT, LU, SK, LI, PR, IM, NO, PT, PL, FI, JP, CA, DE, HU, PH, SE, VA, YT, MK, FR, +MH, RO, FO, GF, AD, HR, DZ, GT, AU, AS, BE, AT +```` -1. Georeference the table using field11 as longitude and field10 as latitude in order to construct the_geom. +### Creation steps -2. Add column iso3 (text) and run sql/build_zipcode_points_table.sql. +1. Download the allCountries.zip file from [GeoNames](www.geonames.org). Import and rename the table as tmp_zipcode_points. You can follow the manual process explained below instead. + + +The columns that are loaded are the following ones: +field_1: corresponding to ISO2 +field_10: corresponds to latitude +field_11: corresponds to longitude +field_2: corresponds to ZIP code + +2. Georeference the table using field11 as longitude and field10 as latitude in order to construct the_geom. + +3. Add column iso3 (text) and run sql/build_zipcode_points_table.sql. **Alternative manual process** -1. Open the allCountries.txt file with Excel an add a new row on top. +Open the allCountries.txt file with Excel an add a new row on top. Delete columns C-I and L. -2. Delete columns C-I and L. +In the first row, add the following columns: iso2, zipcode, lat, long. -3. In the first row, add the following columns: iso2, zipcode, lat, long. +Import the file ignoring step 2. -4. Import the file ignoring step 1. +### Data Sources + +All countries points [GeoNames](www.geonames.org) - http://download.geonames.org/export/zip/allCountries.zip + +### Preparation details _The big size of the dataset may cause interruptions in the processing of the coordinates after uploading the file, manipulating the file before importing is a faster workaround._