57 | | Some tools for importing locations from CSV files are available in {{{controllers/bulk_gis.py}}} |
58 | | * These will move to {{{controllers/importer.py}}} |
59 | | |
| 57 | There is a function available in {{{modules/s3gis.py}}} to import from CSV. |
| 58 | |
| 59 | Example for Pakistan: |
| 60 | {{{ |
| 61 | db.gis_location.truncate() |
| 62 | # L0 |
| 63 | import csv |
| 64 | csv.field_size_limit(2**20 * 10) # 10 megs |
| 65 | db.import_from_csv_file(open('L0.csv','rb')) |
| 66 | db.commit() |
| 67 | # L1 |
| 68 | gis.import_csv('pak_adm1.csv') |
| 69 | db.commit() |
| 70 | # L2 |
| 71 | db(db.gis_location.name=="Baluchistan").update(name="Balochistan") |
| 72 | db(db.gis_location.name=="Northern Areas").update(name="Gilgit Baltistan") |
| 73 | db(db.gis_location.name=="N.W.F.P.").update(name="Khyber Pakhtunkhwa") |
| 74 | db(db.gis_location.name=="F.A.T.A.").update(name="FATA") |
| 75 | db(db.gis_location.name=="F.C.T.").update(name="Islamabad") |
| 76 | db(db.gis_location.name=="Azad Kashmir").update(name="AJK") |
| 77 | gis.import_csv('pak_adm2.csv') |
| 78 | db(db.gis_location.name=="Sind").update(name="Sindh") |
| 79 | db(db.gis_location.name=="AJK").update(name="Pakistan Administered Kashmir") |
| 80 | db(db.gis_location.name=="Islamabad").update(name="Federal Capital Territory") |
| 81 | db(db.gis_location.name=="FATA").update(name="Federally Administered Tribal Areas") |
| 82 | db.commit() |
| 83 | # L2 |
| 84 | db(db.gis_location.name=="Islamabad Capital Territory").update(name="Islamabad") |
| 85 | db(db.gis_location.name=="Jaccobabad").update(name="Jacobabad") |
| 86 | db(db.gis_location.name=="Tando Allahyar").update(name="Tando Allah Yar") |
| 87 | db(db.gis_location.name=="Qambar Shahdad kot").update(name="Qambar Shahdadkot") |
| 88 | gis.import_csv('pak_adm3.csv') |
| 89 | db(db.gis_location.name=="Islamabad").update(name="Islamabad Capital Territory") |
| 90 | db(db.gis_location.name=="Tando Allah Yar").update(name="Tando Allahyar") |
| 91 | db(db.gis_location.name=="Qambar Shahdadkot").update(name="Qambar Shahdad Kot") |
| 92 | db.commit() |
| 93 | }}} |