Thanks for the response. I&#39;m sorry I&#39;m really new to this and am not sure where to transform the line geometry, I know it should be before layer.CreateFeature(feature) but after I add the points to the geometry. Is it before or after feature.SetGeometry(line)? And is the right way to call the transform <br>

target = osr.SpatialReference()<br>target.ImportFromProj4(&#39;+proj=lcc +lat_1=33.000000 +lat_2=45.000000 +lat_0=39.000000 +lon_0=-96.000000 +x_0=0.0 +y_0=0.0 +datum=NAD83&#39;)<br>coordtrans = osr.CoordinateTransformation(source, target)<br>

line.Transform(coordtrans)?<br><br><br><br>import os<br>try:<br>    from osgeo import ogr<br>    from osgeo import osr<br><br>except:<br>    import ogr<br>    import osr<br><br>#~ start driver<br>driver = ogr.GetDriverByName(&#39;ESRI Shapefile&#39;)<br>

#~ set workspace<br>ws = &#39;C:\\Users\\deadpickle\\Desktop\\case study\\verify\\&#39;<br>os.chdir(ws)<br><br>#~ check if it exists<br>if os.path.exists(&#39;test.shp&#39;):<br>    driver.DeleteDataSource(&#39;test.shp&#39;)<br>

<br>#~ create a new shp<br>ds = driver.CreateDataSource(&#39;test.shp&#39;)<br><br>#~ create spatref for new shp<br>source = osr.SpatialReference()<br>source.SetFromUserInput(&#39;WGS84&#39;)<br>#~ source.SetFromUserInput(&#39;+proj=lcc +lat_1=33.000000 +lat_2=45.000000 +lat_0=39.000000 +lon_0=-96.000000 +x_0=0.0 +y_0=0.0 +datum=NAD83&#39;)<br>

#~ create a new data layer<br>layer = ds.CreateLayer(&#39;test&#39;,geom_type=ogr.wkbLineString,srs=source)<br><br>#~ add an id field<br>fieldDefn = ogr.FieldDefn(&#39;id&#39;, ogr.OFTInteger)<br>layer.CreateField(fieldDefn)<br>

<br>#~ create a geometry<br>line = ogr.Geometry(ogr.wkbLineString)<br><br>#~ get the def of the layer, scheme<br>featureDefn = layer.GetLayerDefn()<br><br># create a new feature<br>feature = ogr.Feature(featureDefn)<br><br>

#~ Read 2006track file<br>file = open(&quot;2006track.csv&quot;,&quot;r&quot;)<br>file.readline()<br>lnlist = file.readlines()<br>for lines in lnlist:<br>    value = lines.split(&quot;,&quot;)<br>    if float(value[1]) == 2:<br>

        print value<br>        line.AddPoint(float(value[3]),float(value[2]))<br>        #~ set the field &#39;ID&#39;<br>        feature.SetField(&#39;id&#39;, float(value[1]))<br>        <br>#~ feature = layer.GetFeature(0)<br>

#~ geom = feature.GetGeometryRef()<br><br>#~ change projection to lcc<br>target = osr.SpatialReference()<br>target.ImportFromProj4(&#39;+proj=lcc +lat_1=33.000000 +lat_2=45.000000 +lat_0=39.000000 +lon_0=-96.000000 +x_0=0.0 +y_0=0.0 +datum=NAD83&#39;)<br>

coordtrans = osr.CoordinateTransformation(source, target)<br>line.Transform(coordtrans)<br><br>#~ set the geometry for this shp<br>feature.SetGeometry(line)<br><br># add the feature to the output layer<br>layer.CreateFeature(feature)<br>

<br># destroy the geometry and feature and close the data source<br>ds.Destroy()<br>line.Destroy()<br>feature.Destroy()<br>file.close()<br><br><br><br><br><div class="gmail_quote">On Mon, Mar 1, 2010 at 6:49 PM, Chris Garrard <span dir="ltr">&lt;<a href="mailto:garrard.chris%2Bgis@gmail.com">garrard.chris+gis@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Jamie, Try transforming the line geometry before adding it to the feature.  That should do it.<br>

<font color="#888888"><br>chris</font><div><div></div><div class="h5"><br><br><div class="gmail_quote">On Mon, Mar 1, 2010 at 4:24 PM, deadpickle <span dir="ltr">&lt;<a href="mailto:deadpickle@gmail.com" target="_blank">deadpickle@gmail.com</a>&gt;</span> wrote:<br>




<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Not much of a response going on here. In order to change the shapefile<br>
projection from geographic to projected do I need to reopen the file,<br>
get each feature, and transform the points individually? If so what<br>
calls do I need to invoke?<br>
<br>
On Mar 1, 12:54 pm, Jamie Lahowetz &lt;<a href="mailto:deadpic...@gmail.com" target="_blank">deadpic...@gmail.com</a>&gt; wrote:<br>
&gt; I&#39;m new to GDAL and am usingthe python bindings. I want to transform a newly<br>
&gt; created shapefile from WGS84 to a Lambert Conical Conformal so that I can<br>
&gt; calculate the length of the contained polylines. The script exits with no<br>
&gt; errors but when I look at the shapefile in arcCatalog I see that the<br>
&gt; projection is still WGS84. Any ideas? Also, is there a way to calculate the<br>
&gt; length directly from GDAL? Thanks.<br>
&gt;<br>
&gt; import os<br>
&gt; try:<br>
&gt;     from osgeo import ogr<br>
&gt;     from osgeo import osr<br>
&gt;<br>
&gt; except:<br>
&gt;     import ogr<br>
&gt;     import osr<br>
&gt;<br>
&gt; #~ start driver<br>
&gt; driver = ogr.GetDriverByName(&#39;ESRI Shapefile&#39;)<br>
&gt; #~ set workspace<br>
&gt; ws = &#39;C:\\Users\\deadpickle\\<br>
&gt; Desktop\\case study\\verify\\&#39;<br>
&gt; os.chdir(ws)<br>
&gt;<br>
&gt; #~ check if it exists<br>
&gt; if os.path.exists(&#39;test.shp&#39;):<br>
&gt;     driver.DeleteDataSource(&#39;test.shp&#39;)<br>
&gt;<br>
&gt; #~ create a new shp<br>
&gt; ds = driver.CreateDataSource(&#39;test.shp&#39;)<br>
&gt;<br>
&gt; #~ create spatref for new shp<br>
&gt; source = osr.SpatialReference()<br>
&gt; source.SetFromUserInput(&#39;WGS84&#39;)<br>
&gt;<br>
&gt; #~ create a new data layer<br>
&gt; layer = ds.CreateLayer(&#39;test&#39;,geom_type=ogr.wkbLineString,srs=source)<br>
&gt;<br>
&gt; #~ add an id field<br>
&gt; fieldDefn = ogr.FieldDefn(&#39;id&#39;, ogr.OFTInteger)<br>
&gt; layer.CreateField(fieldDefn)<br>
&gt;<br>
&gt; #~ create a geometry<br>
&gt; line = ogr.Geometry(ogr.wkbLineString)<br>
&gt;<br>
&gt; #~ get the def of the layer, scheme<br>
&gt; featureDefn = layer.GetLayerDefn()<br>
&gt;<br>
&gt; # create a new feature<br>
&gt; feature = ogr.Feature(featureDefn)<br>
&gt;<br>
&gt; #~ Read 2006track file<br>
&gt; file = open(&quot;2006track.csv&quot;,&quot;r&quot;)<br>
&gt; file.readline()<br>
&gt; lnlist = file.readlines()<br>
&gt; for lines in lnlist:<br>
&gt;     value = lines.split(&quot;,&quot;)<br>
&gt;     if float(value[1]) == 2:<br>
&gt;         print value<br>
&gt;         line.AddPoint(float(value[3]),float(value[2]))<br>
&gt;         #~ set the field &#39;ID&#39;<br>
&gt;         feature.SetField(&#39;id&#39;, float(value[1]))<br>
&gt;<br>
&gt; #~ set the geometry for this shp<br>
&gt; feature.SetGeometry(line)<br>
&gt;<br>
&gt; # add the feature to the output layer<br>
&gt; layer.CreateFeature(feature)<br>
&gt;<br>
&gt; #~ feature = layer.GetFeature(0)<br>
&gt; geom = feature.GetGeometryRef()<br>
&gt;<br>
&gt; #~ change projection to lcc<br>
&gt; target = osr.SpatialReference()<br>
&gt; target.ImportFromProj4(&#39;+proj=lcc +lat_1= 33.000000 +lat_2=45.000000<br>
&gt; +lat_0=39.000000 +lon_0=-96.000000 +x_0=0.0 +y_0=0.0&#39;)<br>
&gt; coordtrans = osr.CoordinateTransformation(source, target)<br>
&gt;<br>
&gt; geom.Transform(coordtrans)<br>
&gt;<br>
&gt; # destroy the geometry and feature and close the data source<br>
&gt;<br>
&gt; ds.Destroy()<br>
&gt; line.Destroy()<br>
&gt; feature.Destroy()<br>
&gt; file.close()<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; gdal-dev mailing list<br>
&gt; gdal-...@lists.osgeo.orghttp://<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Jamie Ryan Lahowetz<br>University of Nebraska - Lincoln<br>Graduate Student - Geosciences<br>402.304.0766<br><a href="mailto:jlahowetz@gmail.com">jlahowetz@gmail.com</a><br>