commit
a6a28d7352
@ -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._
|
||||
|
||||
|
||||
|
26
geocoder/postal-codes/sql/build_zipcode_points_table.sql
Normal file
26
geocoder/postal-codes/sql/build_zipcode_points_table.sql
Normal file
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user