Changes between Version 50 and Version 51 of UserGuidelines/GIS/Data


Ignore:
Timestamp:
09/03/10 17:46:31 (14 years ago)
Author:
Fran Boon
Comment:

Pakistan example of using the new s3gis.import_csv() function

Legend:

Unmodified
Added
Removed
Modified
  • UserGuidelines/GIS/Data

    v50 v51  
    5555NB AS_WKT requires OGR v1.6+
    5656
    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 
     57There is a function available in {{{modules/s3gis.py}}} to import from CSV.
     58
     59Example for Pakistan:
     60{{{
     61db.gis_location.truncate()
     62# L0
     63import csv
     64csv.field_size_limit(2**20 * 10)  # 10 megs
     65db.import_from_csv_file(open('L0.csv','rb'))
     66db.commit()
     67# L1
     68gis.import_csv('pak_adm1.csv')
     69db.commit()
     70# L2
     71db(db.gis_location.name=="Baluchistan").update(name="Balochistan")
     72db(db.gis_location.name=="Northern Areas").update(name="Gilgit Baltistan")
     73db(db.gis_location.name=="N.W.F.P.").update(name="Khyber Pakhtunkhwa")
     74db(db.gis_location.name=="F.A.T.A.").update(name="FATA")
     75db(db.gis_location.name=="F.C.T.").update(name="Islamabad")
     76db(db.gis_location.name=="Azad Kashmir").update(name="AJK")
     77gis.import_csv('pak_adm2.csv')
     78db(db.gis_location.name=="Sind").update(name="Sindh")
     79db(db.gis_location.name=="AJK").update(name="Pakistan Administered Kashmir")
     80db(db.gis_location.name=="Islamabad").update(name="Federal Capital Territory")
     81db(db.gis_location.name=="FATA").update(name="Federally Administered Tribal Areas")
     82db.commit()
     83# L2
     84db(db.gis_location.name=="Islamabad Capital Territory").update(name="Islamabad")
     85db(db.gis_location.name=="Jaccobabad").update(name="Jacobabad")
     86db(db.gis_location.name=="Tando Allahyar").update(name="Tando Allah Yar")
     87db(db.gis_location.name=="Qambar Shahdad kot").update(name="Qambar Shahdadkot")
     88gis.import_csv('pak_adm3.csv')
     89db(db.gis_location.name=="Islamabad").update(name="Islamabad Capital Territory")
     90db(db.gis_location.name=="Tando Allah Yar").update(name="Tando Allahyar")
     91db(db.gis_location.name=="Qambar Shahdadkot").update(name="Qambar Shahdad Kot")
     92db.commit()
     93}}}
    6094=== WFS ===
    6195It is possible to use the WFS Plugin to get data into qGIS & thence export into other formats.