diff flys-backend/contrib/shpimporter/shpimporter.py @ 2798:5a654f2e35bc

Added a python tool to import shapefiles into database. flys-backend/trunk@4127 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 07 Mar 2012 20:37:03 +0000
parents
children bd9e76e0b55d
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/contrib/shpimporter/shpimporter.py	Wed Mar 07 20:37:03 2012 +0000
@@ -0,0 +1,30 @@
+import ogr
+import utils
+from uesg import UESG
+
+DBCONN='PG:dbname=flystest1 host=localhost user=flys password=flys port=5432'
+PATH='/**/**/**/flys3-testdaten/Saar/Hydrologie/UeSG/Berechnung'
+
+
+def getImporter():
+    return UESG(DBCONN)
+
+
+if __name__ == '__main__':
+    shapes = utils.findShapefiles(PATH)
+    print "Found %i Shapefiles" % len(shapes)
+
+    types = {}
+    importer = getImporter()
+
+    for shpTuple in shapes:
+        geomType = importer.walkOverShapes(shpTuple)
+        try:
+            num = types[geomType]
+            types[geomType] = num+1
+        except:
+            types[geomType] = 1
+
+    for key in types:
+        print "%i x geometry type %s" % (types[key], key)
+

http://dive4elements.wald.intevation.org