Index: django/contrib/gis/gdal/libgdal.py
===================================================================
--- django/contrib/gis/gdal/libgdal.py	(revision 12588)
+++ django/contrib/gis/gdal/libgdal.py	(working copy)
@@ -65,6 +65,8 @@
     "Returns only the GDAL version number information."
     return _version_info('RELEASE_NAME')
 
+GDAL_VERSION = map(int, gdal_version().split('.')[:2])
+
 def gdal_full_version(): 
     "Returns the full GDAL version information."
     return _version_info('')
Index: django/contrib/gis/gdal/__init__.py
===================================================================
--- django/contrib/gis/gdal/__init__.py	(revision 12588)
+++ django/contrib/gis/gdal/__init__.py	(working copy)
@@ -37,7 +37,7 @@
 try:
     from django.contrib.gis.gdal.driver import Driver
     from django.contrib.gis.gdal.datasource import DataSource
-    from django.contrib.gis.gdal.libgdal import gdal_version, gdal_full_version, gdal_release_date
+    from django.contrib.gis.gdal.libgdal import gdal_version, gdal_full_version, gdal_release_date, GDAL_VERSION
     from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
     from django.contrib.gis.gdal.geometries import OGRGeometry, GEOJSON
     HAS_GDAL = True
Index: django/contrib/gis/gdal/prototypes/geom.py
===================================================================
--- django/contrib/gis/gdal/prototypes/geom.py	(revision 12588)
+++ django/contrib/gis/gdal/prototypes/geom.py	(working copy)
@@ -1,15 +1,14 @@
 from datetime import date
 from ctypes import c_char, c_char_p, c_double, c_int, c_ubyte, c_void_p, POINTER
 from django.contrib.gis.gdal.envelope import OGREnvelope
-from django.contrib.gis.gdal.libgdal import lgdal, gdal_version
+from django.contrib.gis.gdal.libgdal import lgdal, GDAL_VERSION
 from django.contrib.gis.gdal.prototypes.errcheck import check_bool, check_envelope
 from django.contrib.gis.gdal.prototypes.generation import \
     const_string_output, double_output, geom_output, int_output, \
     srs_output, string_output, void_output
 
 # Some prototypes need to be aware of what version GDAL we have.
-major, minor = map(int, gdal_version().split('.')[:2])
-if major <= 1 and minor <= 4:
+if GDAL_VERSION < (1, 5):
     GEOJSON = False
 else:
     GEOJSON = True
Index: django/contrib/gis/gdal/geometries.py
===================================================================
--- django/contrib/gis/gdal/geometries.py	(revision 12588)
+++ django/contrib/gis/gdal/geometries.py	(working copy)
@@ -53,6 +53,7 @@
 # Getting the ctypes prototype functions that interface w/the GDAL C library.
 from django.contrib.gis.gdal.prototypes import geom as capi, srs as srs_api
 GEOJSON = capi.GEOJSON
+GDAL_VERSION = capi.GDAL_VERSION
 
 # For recognizing geometry input.
 from django.contrib.gis.geometry.regex import hex_regex, wkt_regex, json_regex
@@ -400,7 +401,8 @@
         # afterwards.  This is done because of GDAL bug (in versions prior
         # to 1.7) that turns geometries 3D after transformation, see:
         #  http://trac.osgeo.org/gdal/changeset/17792
-        orig_dim = self.coord_dim
+        if GDAL_VERSION < (1, 7):
+            orig_dim = self.coord_dim
 
         # Depending on the input type, use the appropriate OGR routine
         # to perform the transformation.
@@ -412,11 +414,22 @@
             sr = SpatialReference(coord_trans)
             capi.geom_transform_to(self.ptr, sr.ptr)
         else:
-            raise TypeError('Transform only accepts CoordTransform, SpatialReference, string, and integer objects.')
+            raise TypeError('Transform only accepts CoordTransform, '
+                            'SpatialReference, string, and integer objects.')
 
         # Setting with original dimension, see comment above.
-        if self.coord_dim != orig_dim:
-            self.coord_dim = orig_dim
+        if GDAL_VERSION < (1, 7):
+            if isinstance(self, GeometryCollection):
+                # With geometry collections have to set dimension on
+                # each internal geometry reference, as the collection
+                # dimension isn't affected.
+                for i in xrange(len(self)):
+                    internal_ptr = capi.get_geom_ref(self.ptr, i)
+                    if orig_dim != capi.get_coord_dim(internal_ptr):
+                        capi.set_coord_dim(internal_ptr, orig_dim)
+            else:
+                if self.coord_dim != orig_dim:
+                    self.coord_dim = orig_dim
 
     def transform_to(self, srs):
         "For backwards-compatibility."
Index: django/contrib/gis/gdal/tests/test_geom.py
===================================================================
--- django/contrib/gis/gdal/tests/test_geom.py	(revision 12588)
+++ django/contrib/gis/gdal/tests/test_geom.py	(working copy)
@@ -455,8 +455,23 @@
         self.assertEqual(g1, g2)
         self.assertEqual(4326, g2.srs.srid)
         self.assertEqual(g1.srs.wkt, g2.srs.wkt)
-        
 
+    def test08_ogrgeometry_transform_wkt(self): 
+        "Testing dimensions on WKT output of geometries transformed with OGRGeometry.transform" 
+        wkt_2d = "MULTILINESTRING ((0 0,1 1,2 2))"
+        wkt_3d = "MULTILINESTRING ((0 0 0,1 1 1,2 2 2))"
+        srid = 4326
+ 		 
+        geom = OGRGeometry(wkt_2d, srid)
+        geom.transform(srid)
+        self.assertEqual(geom.coord_dim, 2)
+        self.assertEqual(geom.wkt, wkt_2d)
+
+        geom = OGRGeometry(wkt_3d, srid)
+        geom.transform(srid)
+        self.assertEqual(geom.coord_dim, 3)
+        self.assertEqual(geom.wkt, wkt_3d)
+
 def suite():
     s = unittest.TestSuite()
     s.addTest(unittest.makeSuite(OGRGeomTest))
