# Error while getting geographic coordinates of projected location

**URL:** https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849
**Category:** PyLith
**Created:** [May 18, 2021, 11:19am UTC](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849 "2021-05-18T11:19:20Z")
**Posts on this page:** 11
**Page:** 2

<div class="post-metadata">

### Author: ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)
#### Post date: [June 1, 2021, 3:19pm UTC](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849/21 "2021-06-01T15:19:25Z")

</div>

The error indicates that the Proj library could not convert the coordinates of a point in the mesh coordinate system to geographic coordinates while initializing one of the materials. This suggests that there is an error in how you are specifying the coordinate system for your domain.

---

<div class="post-metadata">

### Author: ![alvinakkuncoro](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@alvinakkuncoro](https://community.geodynamics.org/u/alvinakkuncoro)
#### Post date: [June 1, 2021, 3:24pm UTC](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849/22 "2021-06-01T15:24:44Z")

</div>

Does it mean that the projected x y z coordinate of my mesh is not right?

Alvina KK

---

<div class="post-metadata">

### Author: ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)
#### Post date: [June 1, 2021, 3:37pm UTC](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849/23 "2021-06-01T15:37:08Z")

</div>

The coordinates may be correct, but the specification of what that coordinate system is to PyLith/Proj may not be correct.

---

<div class="post-metadata">

### Author: ![alvinakkuncoro](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@alvinakkuncoro](https://community.geodynamics.org/u/alvinakkuncoro)
#### Post date: [June 1, 2021, 3:44pm UTC](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849/24 "2021-06-01T15:44:08Z")

</div>

I converted my coordinate in QGIS using UTM47S and defined the coordinate system in all the cfg file with UTM47S.

Which part of the file should I check to fix this problem?

Alvina KK

---

<div class="post-metadata">

### Author: ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)
#### Post date: [June 1, 2021, 3:57pm UTC](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849/25 "2021-06-01T15:57:55Z")

</div>

How are you specifying the UTM47S projection in your .cfg files? Can you provide the coordinates of one of your points in longitude, latitude in WGS84 and in UTM47S so that we can verify the coordinate transformation is consistent with Proj?

---

<div class="post-metadata">

### Author: ![alvinakkuncoro](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@alvinakkuncoro](https://community.geodynamics.org/u/alvinakkuncoro)
#### Post date: [June 3, 2021, 8:31am UTC](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849/26 "2021-06-03T08:31:41Z")

</div>

Dear Brad,

This is how I assign the projection in my pylith.cfg :  
[pylithapp.mesh\_generator.reader]  
coordsys = spatialdata.geocoords.CSGeoProj  
coordsys.space\_dim = 3  
coordsys.datum\_horiz = WGS84  
coordsys.datum\_vert = mean sea level  
coordsys.projector.projection = utm  
coordsys.projector.proj\_options = +zone=47 +south

I also have attached my files here [Error while getting geographic coordinates of projected location - #3 by alvinakkuncoro](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849/3)

This is one of my coordinate :  
Lon,Lat = 92.05539,5.99347  
x,y = 10247559.53417,663951.76772

Best Regards,  
Alvina KK

---

<div class="post-metadata">

### Author: ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)
#### Post date: [June 7, 2021, 1:52am UTC](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849/27 "2021-06-07T01:52:26Z")

</div>

The point 92.05539E, 5.99347N is in UTM zone 46N.

Proj.4 gives the following conversion if using UTM zone 47S:

```auto
echo "92.05539 5.99347" | proj +proj=utm +zone=47 +south
-270425.05	10667376.03

```

Inverting the projection gives back the origin point:

```auto
echo "-270425.05 10667376.03" | invproj +proj=utm +zone=47 +south -f "%12.4f"
     92.0554 5.9935

```

Inverting the coordinates of your x and y yields:

```auto
echo " 10247559.53417 663951.76772" | invproj +proj=utm +zone=47 +south -f "%12.4f"
   -173.7178 -24.1950

```

There appears to be something wrong with how you are projecting your coordinates.

---

<div class="post-metadata">

### Author: ![alvinakkuncoro](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@alvinakkuncoro](https://community.geodynamics.org/u/alvinakkuncoro)
#### Post date: [June 7, 2021, 8:03am UTC](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849/28 "2021-06-07T08:03:32Z")

</div>

Dear Brad,

I am sorry the previous coordinate I gave you was converted in mercator. So, it must be different.  
My center coordinate is 99.5 , -3.851. It is in UTM zone 47S.  
All my point is converted referred to this coordinate.  
The converted coordinate in QGIS (utm47s) : 555513.381 , 9574298.167.  
I have checked in proj (utm47s) : 555513.40 9574326.09

The previous coordinate (92.05539,5.99347),  
Converted coordinate in QGIS (utm 47S) : -270424.6511 , 10667376  
In proj (utm47s) : -270425.05 10667376.03

Best Regards,  
Alvina KK

---

<div class="post-metadata">

### Author: ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)
#### Post date: [June 7, 2021, 3:04pm UTC](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849/29 "2021-06-07T15:04:45Z")

</div>

I downloaded your Exodus file. It has 4326 points where the coordinates are NaN. This appears to be causing the problem.

Note: It looks like your mesh is 1700 km x 1000 km x 200 km. If you use UTM coordinates, I would expect significant distortion because UTM was not designed for such large regions. I recommend using a more appropriate projection like Albers equal area.

---

<div class="post-metadata">

### Author: ![alvinakkuncoro](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@alvinakkuncoro](https://community.geodynamics.org/u/alvinakkuncoro)
#### Post date: [June 7, 2021, 3:43pm UTC](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849/30 "2021-06-07T15:43:38Z")

</div>

Dear Brad,

Thank your for finding the problem.

May I know what can cause this NaN value after I created the mesh?

I have prepared the geometry in Mercator as well just to prepare this UTM problem can’t be solved.

Alvina K K

---

<div class="post-metadata">

### Author: ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)
#### Post date: [June 7, 2021, 4:11pm UTC](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849/31 "2021-06-07T16:11:38Z")

</div>

I have no idea where the NaNs in your mesh are coming from. I would try a much coarser mesh and see if the NaNs go away.

Here is the code you can use to check if there are NanS in the coordinates of your vertices:

```auto
#!/usr/bin/env nemesis

import numpy
import netCDF4

exodus = netCDF4.Dataset("mesh/mesh_tet_smooth.exo", 'r')
x = exodus.variables['coordx'][:]
y = exodus.variables['coordy'][:]
z = exodus.variables['coordz'][:]

xnan = numpy.isnan(x)
ynan = numpy.isnan(y)
znan = numpy.isnan(z)

print("Number of NaNs: x:%d, y:%d, z:%d" % (numpy.sum(xnan), numpy.sum(ynan), numpy.sum(znan)))

```

[Previous page](https://community.geodynamics.org/t/error-while-getting-geographic-coordinates-of-projected-location/1849.md?page=1)
