Adds SQL for populating cities table

This commit is contained in:
Carla
2015-06-15 17:01:19 +02:00
parent 103dd5d7df
commit 81779fdfc5
+18 -19
View File
@@ -7,7 +7,6 @@
--- in searches and reduces search cost / time --- --- in searches and reduces search cost / time ---
--- --- --- ---
--- please, generate a backup of the current global_cities_points_limited table --- --- please, generate a backup of the current global_cities_points_limited table ---
--- before proceeding, as changes cannot be undone ---
--- --- --- ---
-- clear all existing data from the table -- -- clear all existing data from the table --
@@ -22,7 +21,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- insert data from source table (allcountries) to the table -- insert data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode IS null; WHERE featcode IS null;
@@ -30,7 +29,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- capital of a political entity -- capital of a political entity
-- insert PPLC data from source table (allcountries) to the table -- insert PPLC data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLC'; WHERE featcode = 'PPLC';
@@ -38,7 +37,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- populated place a city, town, village, or other agglomeration of buildings where people live and work -- populated place a city, town, village, or other agglomeration of buildings where people live and work
-- insert PPL data from source table (allcountries) to the table -- insert PPL data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPL'; WHERE featcode = 'PPL';
@@ -46,7 +45,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- seat of a first-order administrative division (PPLC takes precedence over PPLA) -- seat of a first-order administrative division (PPLC takes precedence over PPLA)
-- insert PPLA data from source table (allcountries) to the table -- insert PPLA data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLA'; WHERE featcode = 'PPLA';
@@ -54,7 +53,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- seat of a second-order administrative division -- seat of a second-order administrative division
-- insert PPLA2 data from source table (allcountries) to the table -- insert PPLA2 data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLA2'; WHERE featcode = 'PPLA2';
@@ -62,7 +61,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- seat of a third-order administrative division -- seat of a third-order administrative division
-- insert PPLA3 data from source table (allcountries) to the table -- insert PPLA3 data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLA3'; WHERE featcode = 'PPLA3';
@@ -70,7 +69,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- seat of a fourth-order administrative division -- seat of a fourth-order administrative division
-- insert PPLA4 data from source table (allcountries) to the table -- insert PPLA4 data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLA4'; WHERE featcode = 'PPLA4';
@@ -78,7 +77,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- historical capital of a political entity, a former capital of a political entity -- historical capital of a political entity, a former capital of a political entity
-- insert PPLCH data from source table (allcountries) to the table -- insert PPLCH data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLCH'; WHERE featcode = 'PPLCH';
@@ -86,7 +85,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- farm village a populated place where the population is largely engaged in agricultural activities -- farm village a populated place where the population is largely engaged in agricultural activities
-- insert PPLF data from source table (allcountries) to the table -- insert PPLF data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLF'; WHERE featcode = 'PPLF';
@@ -94,7 +93,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- seat of government of a political entity -- seat of government of a political entity
-- insert PPLG data from source table (allcountries) to the table -- insert PPLG data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLG'; WHERE featcode = 'PPLG';
@@ -102,7 +101,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- historical populated place a populated place that no longer exists -- historical populated place a populated place that no longer exists
-- insert PPLH data from source table (allcountries) to the table -- insert PPLH data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLH'; WHERE featcode = 'PPLH';
@@ -110,7 +109,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- populated locality an area similar to a locality but with a small group of dwellings or other buildings -- populated locality an area similar to a locality but with a small group of dwellings or other buildings
-- insert PPLL data from source table (allcountries) to the table -- insert PPLL data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLL'; WHERE featcode = 'PPLL';
@@ -118,7 +117,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- abandoned populated place -- abandoned populated place
-- insert PPLQ data from source table (allcountries) to the table -- insert PPLQ data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLQ'; WHERE featcode = 'PPLQ';
@@ -126,7 +125,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- religious populated place a populated place whose population is largely engaged in religious occupations -- religious populated place a populated place whose population is largely engaged in religious occupations
-- insert PPLR data from source table (allcountries) to the table -- insert PPLR data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLR'; WHERE featcode = 'PPLR';
@@ -134,7 +133,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- populated places cities, towns, villages, or other agglomerations of buildings where people live and work -- populated places cities, towns, villages, or other agglomerations of buildings where people live and work
-- insert PPLS data from source table (allcountries) to the table -- insert PPLS data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLS'; WHERE featcode = 'PPLS';
@@ -142,7 +141,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- destroyed populated place a village, town or city destroyed by a natural disaster, or by war -- destroyed populated place a village, town or city destroyed by a natural disaster, or by war
-- insert PPLW data from source table (allcountries) to the table -- insert PPLW data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLW'; WHERE featcode = 'PPLW';
@@ -150,7 +149,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- section of populated place -- section of populated place
-- insert PPLX data from source table (allcountries) to the table -- insert PPLX data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'PPLX'; WHERE featcode = 'PPLX';
@@ -158,7 +157,7 @@ INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admi
-- israeli settlement -- israeli settlement
-- insert STLMT data from source table (allcountries) to the table -- insert STLMT data from source table (allcountries) to the table
-- it assumes that the source is called "allcountries" -- it assumes that the source is called "allcountries"
INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid, gtopo30, iso2, lowername, name, population) INSERT INTO global_cities_points_limited (the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geoname_id, gtopo30, iso2, lowername, name, population)
SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population SELECT the_geom, admin1, admin2, admin3, admin4, altnames, asciiname, cc2, featclass, featcode, geonameid::int, gtopo30, country, lower(name) as lowername, name, population
FROM allcountries FROM allcountries
WHERE featcode = 'STLMT'; WHERE featcode = 'STLMT';