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 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 diff --git a/geocoder/postal-codes/README.md b/geocoder/postal-codes/README.md index dd49dc9..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 @@ -20,6 +26,58 @@ French polygons - http://www.data.gouv.fr/dataset/fond-de-carte-des-codes-postau ### 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) -todo +### 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: + +```` +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 +```` + +### 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 +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. + +### 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._ + + 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; + +