# Projection problem using shapefiles

**URL:** <https://mapwindow.discourse.group/t/projection-problem-using-shapefiles/1132>\
**Category:** MapWinGIS\
**Created:** [November 9, 2021, 9:55am UTC](https://mapwindow.discourse.group/t/projection-problem-using-shapefiles/1132 "2021-11-09T09:55:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Airmech](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/airmech/32/573_2.png) [@Airmech](https://mapwindow.discourse.group/u/Airmech)\
**Post date:** [November 9, 2021, 9:55am UTC](https://mapwindow.discourse.group/t/projection-problem-using-shapefiles/1132/1 "2021-11-09T09:55:54Z")

</div>

Hi,  
I’m having a problem with changing the projection of the map. If I use WGS84 the points in the loaded shapefiles display in the correct place, but, if I change to Google\_mercator the points all end up in a block at the equator on the Grenwich meridian.  
Am I missing something or doing something wrong?

Thanks  
Trevor

---

<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:** [November 14, 2021, 5:10am UTC](https://mapwindow.discourse.group/t/projection-problem-using-shapefiles/1132/2 "2021-11-14T05:10:21Z")

</div>

Hello @Airmech, and welcome.

It sounds like the points themselves are in DMS (is there a PRJ file?), and thus are located properly in WGS84. If you just change the projection of the map, the points are then interpreted by the map projection, so instead of a point being 40 degrees north, the point would be displayed 40 _meters north_ (of the equator) since Google Mercator is in meters.

What you probably want to do is tell the map to reproject the layers on-the-fly at load time. Before you load the layer, set the Global property [ReprojectLayersOnAdding](https://www.mapwindow.org/documentation/mapwingis4.9/class_global_settings.html#a3b13db883be4cef7fd2f04fc0e7ccf7f) = true, something like.

```
GlobalSettings gs = new GlobalSettings();
gs.ReprojectLayersOnAdding = true;

```

See if that solves it.

Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![Airmech](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/airmech/32/573_2.png) [@Airmech](https://mapwindow.discourse.group/u/Airmech)\
**Post date:** [November 14, 2021, 9:46am UTC](https://mapwindow.discourse.group/t/projection-problem-using-shapefiles/1132/3 "2021-11-14T09:46:42Z")

</div>

Hi Jerry,  
No, the is no PRJ file. I’ll give the ReprojectLayers a go in the morning and see how that works out.  
Thanks  
Trevor

---

<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:** [November 15, 2021, 12:49am UTC](https://mapwindow.discourse.group/t/projection-problem-using-shapefiles/1132/4 "2021-11-15T00:49:00Z")

</div>

It may well be that without a PRJ file, the reproject-on-load won’t know what to do. Other options would be to either create a PRJ to go the with the Shapefile, or to programmatically set the projection (using the GeoProjection class) to the ‘known’ WGS84, then call the either the [Reproject](https://www.mapwindow.org/documentation/mapwingis4.9/group __shapefile__ geoprocessing.html#gaa248de52c40fadf103ce50d3c349d6da) or ReprojectInPlace method.

Let me know if you need more specific direction regarding this.

Jerry.

---

<div class="post-metadata">

**Author:** ![Airmech](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/airmech/32/573_2.png) [@Airmech](https://mapwindow.discourse.group/u/Airmech)\
**Post date:** [November 20, 2021, 11:05am UTC](https://mapwindow.discourse.group/t/projection-problem-using-shapefiles/1132/5 "2021-11-20T11:05:53Z")

</div>

Hi Jerry,  
I tried ReprojectLayersOnAdding but it was painfully slow reprojecting the shapes on app start and is unworkable for my needs.  
I have been thinking about copying the shapefile and reprojecting the copy in the background. That way when the user changes projection, all I have to do is load the associated shapes with the right projection. Any suggestions how I should do that?

---

<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:** [November 22, 2021, 6:09am UTC](https://mapwindow.discourse.group/t/projection-problem-using-shapefiles/1132/6 "2021-11-22T06:09:32Z")

</div>

Hello @Airmech

I don’t know your particular use-case, or if indeed the user is regularly ‘changing’ the projection, but if you want to set up a process by which you can reproject the layer, without first loading the layer, you could try using the Utils class function, [ReprojectShapefile](https://www.mapwindow.org/documentation/mapwingis4.9/class_utils.html#af6d67276705decf24a28fa157f581849). Hope that helps.

Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![Airmech](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/airmech/32/573_2.png) [@Airmech](https://mapwindow.discourse.group/u/Airmech)\
**Post date:** [November 22, 2021, 10:33am UTC](https://mapwindow.discourse.group/t/projection-problem-using-shapefiles/1132/7 "2021-11-22T10:33:53Z")

</div>

Hi Jerry,

Just one more question what do I put in for the Projection when I reproject the shapes?  
I can’t seem to find any reference to the GeoProjection in the help or the header file.  
I’m going from WGS84 to Google Mercator.

Thanks again,

Trevor.

---

<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:** [November 24, 2021, 3:35am UTC](https://mapwindow.discourse.group/t/projection-problem-using-shapefiles/1132/8 "2021-11-24T03:35:44Z")

</div>

Hello. Sometimes I find it easiest to do a quick search, or check the EPSG site.

Here you can see WGS84 is 4326, and Google Mercator is 3857.

 ![image](https://global.discourse-cdn.com/free1/uploads/mapwindow1/original/1X/613d321e6b5e207904930a00f6897e495f55c409.png)

---

<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, 2:40pm UTC](https://mapwindow.discourse.group/t/projection-problem-using-shapefiles/1132/9 "2022-01-05T14:40:25Z")

</div>


