# Reproject vs ReprojectInPlace

**URL:** <https://mapwindow.discourse.group/t/reproject-vs-reprojectinplace/495>\
**Category:** MapWinGIS\
**Created:** [March 18, 2020, 2:31pm UTC](https://mapwindow.discourse.group/t/reproject-vs-reprojectinplace/495 "2020-03-18T14:31:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![robhoney](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@robhoney](https://mapwindow.discourse.group/u/robhoney)\
**Post date:** [March 18, 2020, 2:31pm UTC](https://mapwindow.discourse.group/t/reproject-vs-reprojectinplace/495/1 "2020-03-18T14:31:32Z")

</div>

Hello all,

Can you think of any reason why this works:

> var newShp = shp.Reproject(myGeoProjection, ref changedCount);

but this returns false and does not work:

> shp.ReprojectInPlace(myGeoProjection, ref changedCount);

Are there any caveats when using ReprojectInPlace?

Regards,

Rob H

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [March 18, 2020, 4:08pm UTC](https://mapwindow.discourse.group/t/reproject-vs-reprojectinplace/495/2 "2020-03-18T16:08:08Z")

</div>

Hello Rob.

There are a few subtle differences internally.

By any chance was an error message available? something like `shapefile.get_ErrorMsg(shapefile.LastErrorCode)`

---

<div class="post-metadata">

**Author:** ![robhoney](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@robhoney](https://mapwindow.discourse.group/u/robhoney)\
**Post date:** [March 18, 2020, 4:51pm UTC](https://mapwindow.discourse.group/t/reproject-vs-reprojectinplace/495/3 "2020-03-18T16:51:11Z")

</div>

Hi Jerry,

Thanks for your message. That call returns “No Error” - however, “LastErrorCode” is actually set to 208.

Regards,

Rob

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [March 18, 2020, 5:05pm UTC](https://mapwindow.discourse.group/t/reproject-vs-reprojectinplace/495/4 "2020-03-18T17:05:52Z")

</div>

Thanks.

208 is “Shapefile function can not be executed in non-edit mode”. So I’m guessing that perhaps it’s a disk-based Shapefile, not an in-memory Shapefile, which I believe are always considered in edit mode.

This probably makes sense since it does indeed have to edit the shapes. Try wrapping it in `StartEditingShapes/StopEditingShapes`, and see if that resolves it.

Regards.

---

<div class="post-metadata">

**Author:** ![robhoney](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@robhoney](https://mapwindow.discourse.group/u/robhoney)\
**Post date:** [March 19, 2020, 9:35am UTC](https://mapwindow.discourse.group/t/reproject-vs-reprojectinplace/495/5 "2020-03-19T09:35:46Z")

</div>

Thanks Jerry, wrapping it in StartEditingShapes/StopEditingShapes has done the trick.

---

<div class="post-metadata">

**Author:** ![robhoney](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@robhoney](https://mapwindow.discourse.group/u/robhoney)\
**Post date:** [March 19, 2020, 4:18pm UTC](https://mapwindow.discourse.group/t/reproject-vs-reprojectinplace/495/6 "2020-03-19T16:18:06Z")

</div>

I do have a related, follow up question…

When I add an ascii grid layer, this triggers the same `LayerProjectionIsEmptyEvent` event that I am using to reproject the shapefile in place and I can see the layer is coming through as a tif, which all makes sense - but is there a way I can do a similar reprojection of the image, or would I have to reproject the underlying ascii grid file before adding via `AddLayer`

Regards,

Rob

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [March 19, 2020, 5:33pm UTC](https://mapwindow.discourse.group/t/reproject-vs-reprojectinplace/495/7 "2020-03-19T17:33:09Z")

</div>

Hello Rob.

I don’t know too much about this; perhaps someone else has some insight. What I think you would want to look at is ‘warping’, although I don’t think you can warp on-the-fly like you can a vector layer. There’s a GDALWarp function in the Utilities class; I would probably start there.

Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 5, 2022, 3:09pm UTC](https://mapwindow.discourse.group/t/reproject-vs-reprojectinplace/495/8 "2022-01-05T15:09:00Z")

</div>


