# How to save a Layer to a Projection?

**URL:** <https://community.thinkgeo.com/t/how-to-save-a-layer-to-a-projection/201>\
**Category:** WinForms\
**Created:** [February 2, 2009, 2:55pm UTC](https://community.thinkgeo.com/t/how-to-save-a-layer-to-a-projection/201 "2009-02-02T14:55:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adolfo](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/3da27b/32.png) [@Adolfo](https://community.thinkgeo.com/u/Adolfo)\
**Post date:** [February 2, 2009, 2:55pm UTC](https://community.thinkgeo.com/t/how-to-save-a-layer-to-a-projection/201/1 "2009-02-02T14:55:21Z")

</div>

&nbsp;&nbsp;In&nbsp;2.x,&nbsp;there&nbsp;is&nbsp;a&nbsp;convenient&nbsp;way&nbsp;to&nbsp;save&nbsp;a&nbsp;Layer&nbsp;to&nbsp;a&nbsp;projection&nbsp;to&nbsp;avoid&nbsp;having&nbsp;to&nbsp;do&nbsp;projection&nbsp;on&nbsp;the&nbsp;fly.&nbsp;The&nbsp;layer&nbsp;has&nbsp;the&nbsp;function&nbsp;SaveToProjection.

Dim&nbsp;Layer&nbsp;As&nbsp;New&nbsp;Layer("...\MyLayer.shp")  
  
Dim&nbsp;GeoToUTM17N&nbsp;As&nbsp;New&nbsp;GeodeticToUTM17N()

Layer.SaveToProjection("UTM17N",&nbsp;GeoToUTM17N&nbsp;,&nbsp;True)

&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;I&nbsp;could&nbsp;not&nbsp;find&nbsp;a&nbsp;such&nbsp;a&nbsp;simple&nbsp;API&nbsp;in&nbsp;3.x.&nbsp;What&nbsp;would&nbsp;be&nbsp;the&nbsp;way&nbsp;to&nbsp;accomplish&nbsp;that&nbsp;task&nbsp;in&nbsp;3.x?&nbsp;Are&nbsp;you&nbsp;planning&nbsp;on&nbsp;offering&nbsp;a&nbsp;simple&nbsp;API&nbsp;for&nbsp;that&nbsp;in&nbsp;the&nbsp;near&nbsp;future?

Thank&nbsp;you.

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Ben](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ben/32/25720_2.png) [@Ben](https://community.thinkgeo.com/u/Ben)\
**Post date:** [February 3, 2009, 12:58am UTC](https://community.thinkgeo.com/t/how-to-save-a-layer-to-a-projection/201/2 "2009-02-03T00:58:39Z")

</div>

Adolfo,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;reminding.&nbsp;I&nbsp;have&nbsp;writen&nbsp;it&nbsp;down&nbsp;and&nbsp;we&nbsp;will&nbsp;discuss&nbsp;it.&nbsp;I&nbsp;believe&nbsp;we&nbsp;will&nbsp;add&nbsp;a&nbsp;similar&nbsp;API&nbsp;in&nbsp;the&nbsp;near&nbsp;future.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Now&nbsp;you&nbsp;can&nbsp;accomplish&nbsp;this&nbsp;with&nbsp;the&nbsp;following&nbsp;code.&nbsp;  
&nbsp;&nbsp;  
&nbsp;`            string sourceShapeFile = @"C:\temp\Countries02.shp";            string targetShapeFile = @"C:\temp\Countries02Test.shp";             ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(sourceShapeFile);            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;             worldLayer.Open();            Collection<Feature> allFeatures = worldLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);            worldLayer.Close();             ShapeFileFeatureSource.CloneShapeFileStructure(sourceShapeFile, targetShapeFile);            ShapeFileFeatureSource targetFeatureSource = new ShapeFileFeatureSource(targetShapeFile, ShapeFileReadWriteMode.ReadWrite);            targetFeatureSource.Open();            proj4Projection.Open();            targetFeatureSource.BeginTransaction();            foreach (Feature feature in allFeatures)            {                Feature projectedFeature = proj4Projection.ConvertToExternalProjection(feature);                targetFeatureSource.AddFeature(projectedFeature);            }            TransactionResult result = targetFeatureSource.CommitTransaction();            proj4Projection.Close();            targetFeatureSource.Close();`&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Ben

---

<div class="post-metadata">

**Author:** ![Adolfo](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/3da27b/32.png) [@Adolfo](https://community.thinkgeo.com/u/Adolfo)\
**Post date:** [February 3, 2009, 10:42am UTC](https://community.thinkgeo.com/t/how-to-save-a-layer-to-a-projection/201/3 "2009-02-03T10:42:42Z")

</div>

Thank&nbsp;you,&nbsp;Ben.&nbsp;I&nbsp;used&nbsp;your&nbsp;code&nbsp;and&nbsp;I&nbsp;succesfully&nbsp;save&nbsp;a&nbsp;shapefile&nbsp;to&nbsp;UTM&nbsp;from&nbsp;an&nbsp;original&nbsp;shapefile&nbsp;in&nbsp;StatePlane.&nbsp;On&nbsp;my&nbsp;machine,&nbsp;on&nbsp;a&nbsp;23&nbsp;Meg&nbsp;shapefile,&nbsp;it&nbsp;took&nbsp;about&nbsp;35&nbsp;seconds&nbsp;so&nbsp;I&nbsp;guess&nbsp;this&nbsp;is&nbsp;decent&nbsp;performance.

&nbsp;

---

<div class="post-metadata">

**Author:** ![Ben](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ben/32/25720_2.png) [@Ben](https://community.thinkgeo.com/u/Ben)\
**Post date:** [February 4, 2009, 1:49am UTC](https://community.thinkgeo.com/t/how-to-save-a-layer-to-a-projection/201/4 "2009-02-04T01:49:25Z")

</div>

Great!&nbsp;We&nbsp;are&nbsp;working&nbsp;on&nbsp;this&nbsp;and&nbsp;the&nbsp;API&nbsp;(static&nbsp;ShapeFileFeatureSource.SaveToProjection)&nbsp;will&nbsp;be&nbsp;available&nbsp;in&nbsp;the&nbsp;upcoming&nbsp;version.&nbsp;Keep&nbsp;letting&nbsp;us&nbsp;know&nbsp;your&nbsp;great&nbsp;ideas,&nbsp;Adolfo.&nbsp;:)&nbsp;  
&nbsp;&nbsp;  
&nbsp;Ben.&nbsp;
