| | 35 | File = open(import_file, "r") |
| | 36 | resource.import_xml(File, format="csv", stylesheet=stylesheet) |
| | 37 | db.commit() |
| | 38 | gis.update_location_tree() |
| | 39 | db.commit() |
| | 40 | }}} |
| | 41 | |
| | 42 | === Vietnam === |
| | 43 | Admin Boundaries: |
| | 44 | * [http://eden.sahanafoundation.org/downloads/VN_Lx.7z VN_Lx.7z] |
| | 45 | |
| | 46 | These have come originally from [http://gadm.org GADM] but with their L1 removed (so we use their L2 as our L1, etc) |
| | 47 | * GADM file has terrible problems with place names: at least 3 different encodings! |
| | 48 | * These have mostly been resolved & the file contains place names with no diacritics (to make it easier for non-Vietnamese to search for such places) as well as Vi name_l10n |
| | 49 | * Many updated boundaries from http://gis.chinhphu.vn by selecting the place & then using this JS: |
| | 50 | {{{ |
| | 51 | points = plHighlight[0].latlngs[0]; |
| | 52 | output = 'POLYGON (('; |
| | 53 | for (var i=0; i < points.length; i++) { |
| | 54 | p = points[i]; |
| | 55 | output += p.longitude; |
| | 56 | output += ' '; |
| | 57 | output += p.latitude; |
| | 58 | output += ','; |
| | 59 | } |
| | 60 | output = output.slice(0, -1); |
| | 61 | output += '))'; |
| | 62 | }}} |
| | 63 | or |
| | 64 | {{{ |
| | 65 | output = 'MULTIPOLYGON ((('; |
| | 66 | points = plHighlight[0].latlngs[0]; |
| | 67 | for (var i=0; i < points.length; i++) { |
| | 68 | p = points[i]; |
| | 69 | output += p.longitude; |
| | 70 | output += ' '; |
| | 71 | output += p.latitude; |
| | 72 | output += ','; |
| | 73 | } |
| | 74 | output = output.slice(0, -1); // Strip comma |
| | 75 | output += ')),(('; |
| | 76 | points = plHighlight[1].latlngs[0]; |
| | 77 | for (var i=0; i < points.length; i++) { |
| | 78 | p = points[i]; |
| | 79 | output += p.longitude; |
| | 80 | output += ' '; |
| | 81 | output += p.latitude; |
| | 82 | output += ','; |
| | 83 | } |
| | 84 | output = output.slice(0, -1); // Strip comma |
| | 85 | output += ')))'; |
| | 86 | }}} |
| | 87 | & then converted to WGS84 using: |
| | 88 | {{{ |
| | 89 | ogr2ogr -f CSV CSV '.\VN2000 Polygons.csv' -s_srs EPSG:3405 -t_srs EPSG:4326 -lco GEOMETRY=AS_WKT |
| | 90 | }}} |
| | 91 | * Old boundaries have been left and start / end dates have been added from Wikipedia. |
| | 92 | |
| | 93 | Use [http://7zip.org 7-Zip] to extract to your web2py folder & then install like this: |
| | 94 | {{{ |
| | 95 | cd /home/web2py |
| | 96 | p7zip -d VN_Lx.7z |
| | 97 | python web2py.py -S eden -M |
| | 98 | |
| | 99 | auth.override = True |
| | 100 | resource = s3db.resource("gis_location") |
| | 101 | stylesheet = os.path.join(request.folder, "static", "formats", "s3csv", "gis", "location.xsl") |
| | 102 | import_file = "VN_L0.csv" |
| | 103 | File = open(import_file, "r") |
| | 104 | resource.import_xml(File, format="csv", stylesheet=stylesheet) |
| | 105 | db.commit() |
| | 106 | import_file = "VN_L1.csv" |
| | 107 | File = open(import_file, "r") |
| | 108 | resource.import_xml(File, format="csv", stylesheet=stylesheet) |
| | 109 | db.commit() |
| | 110 | import_file = "VN_L2.csv" |
| | 111 | File = open(import_file, "r") |
| | 112 | resource.import_xml(File, format="csv", stylesheet=stylesheet) |
| | 113 | db.commit() |
| | 114 | import_file = "VN_L3.csv" |