# Rotating MapPrinterLayer

**URL:** <https://community.thinkgeo.com/t/rotating-mapprinterlayer/9054>\
**Category:** WinForms\
**Created:** [April 12, 2018, 5:30pm UTC](https://community.thinkgeo.com/t/rotating-mapprinterlayer/9054 "2018-04-12T17:30:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hartwig](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/hartwig/32/19013_2.png) [@Hartwig](https://community.thinkgeo.com/u/Hartwig)\
**Post date:** [April 12, 2018, 5:30pm UTC](https://community.thinkgeo.com/t/rotating-mapprinterlayer/9054/1 "2018-04-12T17:30:00Z")

</div>

Hi all,

I’m trying to plot a map. The user should be able to rotate the to fit paper best way…  
Therefore I’m using the code :

```
'Define a Rotation Projection
Public rotateProjection As New RotationProjection

'Load the MapLayer to be printed
'the Map will be build by a GeoTiffLayer with Projection (EPSG=25832)
MyMapLayer = LoadGeoTiffLayer("c:\Users\ht\Documents\gisme.tif", BaseSrid)
mapPrinterLayer.Layers.Add(MyMapLayer)

'When map is loaded the user will rotate the map
rotateProjection.Angle = rotation.Text
MyMapLayer.ImageSource.Projection = rotateProjection
winformsMap1.Refresh()

```

My question: The Map doesn’t rotate.  
What’s wrong?

Do you have a snipet for rotating and printing a RasterLayer.

Regards  
Hardy

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [April 13, 2018, 8:40am UTC](https://community.thinkgeo.com/t/rotating-mapprinterlayer/9054/2 "2018-04-13T08:40:11Z")

</div>

Hi Hardy,

I guess that maybe related with the data, because I tried our sample data in our sample, it works well.

[9054.zip](https://community.thinkgeo.com/uploads/default/original/3X/6/b/6b6f9ba04b066bcbb7fa2b190828239ceb4bd50f.zip) (1.2 MB)

 ![](https://community.thinkgeo.com/uploads/default/original/3X/b/6/b64002d7afd266fb12b403c2c9b2460a720cc65d.png)

Regards,

Ethan

---

<div class="post-metadata">

**Author:** ![Hartwig](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/hartwig/32/19013_2.png) [@Hartwig](https://community.thinkgeo.com/u/Hartwig)\
**Post date:** [April 13, 2018, 12:59pm UTC](https://community.thinkgeo.com/t/rotating-mapprinterlayer/9054/3 "2018-04-13T12:59:11Z")

</div>

Hi Ethan,

I have done several checks with the data: Using world.tif works well.  
But using any other TIF File (with compression or not, size from 1.5MB to 400MB) will crash when setting the RotationProjection.  
After setting the Rotation the map can’t be refreshed. MapSuite will crash in different exceptions. Most “the layer has no bounding box”.

It seems to me that there is a bug in MapSuite handling Raster with Rotation.

[Data.zip](https://community.thinkgeo.com/uploads/default/original/3X/c/d/cde028e0dca9ec9d8743d7f1888152381ae5030d.zip) (1.4 MB)

Please try with one of my files.

Regards  
Hardy

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [April 16, 2018, 9:08am UTC](https://community.thinkgeo.com/t/rotating-mapprinterlayer/9054/4 "2018-04-16T09:08:56Z")

</div>

Hi Hardy,

Thanks for your data and your research. I reproduce that and finally found that’s because we need to set another property here:

rotationProjection.PivotCenter = layer.GetBoundingBox().GetCenterPoint();

The default value is 0,0 and that’s why the world.tif works well because its center point is just the 0,0.

But it looks the property is not easy to be used, please see my code as below:

```
  GeoTiffRasterLayer layer = new GeoTiffRasterLayer(@"..\..\AppData\tmp.tif", @"..\..\AppData\tmp.tfw");
        layer.Open();
        rotationProjection.PivotCenter = layer.GetBoundingBox().GetCenterPoint();
        layer.Close();

        layer.ImageSource.Projection = rotationProjection;
        layer.Open();

        winformsMap1.CurrentExtent = layer.GetBoundingBox();

```

Or you can set rotationProjection.Open(); instead of close the layer and open it again, that will works also.

Please notice, you should want to get the center point before assign rotation projection, or else the value is incorrect because.

I will let our developer know it and see whether they can enhancement the RotationProjection in future.

Regards,

Ethan

---

<div class="post-metadata">

**Author:** ![Hartwig](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/hartwig/32/19013_2.png) [@Hartwig](https://community.thinkgeo.com/u/Hartwig)\
**Post date:** [April 17, 2018, 10:14am UTC](https://community.thinkgeo.com/t/rotating-mapprinterlayer/9054/5 "2018-04-17T10:14:48Z")

</div>

Ethan,  
it’s working fine.  
Thank you for support.

Regards  
Hardy

---

<div class="post-metadata">

**Author:** ![Mark\_Lee](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/c5a1d2/32.png) [@Mark\_Lee](https://community.thinkgeo.com/u/Mark_Lee)\
**Post date:** [April 18, 2018, 1:30am UTC](https://community.thinkgeo.com/t/rotating-mapprinterlayer/9054/6 "2018-04-18T01:30:37Z")

</div>

Hi Hardy,

It’s glad to hear that works fine.  
If there is any issue when using MapSuite, please feel free to let us know that.

Thanks  
Mark
