Question

Convert lat long to utm

  • 5 December 2014
  • 2 replies
  • 40 views

Hello,

 

 

I have a csv containg lat long data in several diffrent utm zones. I would like to add the utm northing easting and ZONE as attributes to my feature. I thought I could use the vertexcreator to create a point reproject it into utm using the reprojector and then exctract the text using the geometryextractor, but the reprojecter requires that the utm zone be entered. My only thought would be to have a testfilter transformer test the longitude to see which zone it should be in and then have a reprojector set up for each zone but this just seems messy. there must be a better way. Any Ideas?

2 replies

Userlevel 2
Badge +17
Hi,

 

 

Sure, you can use the VertexCreator+Reprojector+CoordinateExtractor.

 

Alternatively, the AttributeReprojector can also be used if you don't need to create point geometry.

 

Regarding UTM zone choice, consider using the Conditional Value for the "Destination Coordinate System" setting. 

 

 

Takashi
Userlevel 4
Hi,

 

 

if you've got a LatLong geometry, you can insert a PythonCaller with the following code:

 

 

---

 

import fmeobjects

 

import math

 

 

def get_utm_zone(feature):

 

    first_coord = feature.getCoordinate(0)

 

    lon, lat = first_coord[:2]

 

    

 

    utmzone = int((math.floor((lon + 180.0)/6) % 60) + 1)

 

    # Special cases for Norway and Svalbard

 

    if lat > 55.0 and utmzone == 31 and lat < 64.0 and lon > 2.0:

 

        utmzone = 32

 

    elif lat > 71.0 and utmzone == 32 and lon < 9.0:

 

        utmzone = 31

 

    elif lat > 71.0 and utmzone == 32 and lon > 8.0:

 

        utmzone = 33

 

    elif lat > 71.0 and utmzone == 34 and lon < 21.0:

 

        utmzone = 33

 

    elif lat > 71.0 and utmzone == 34 and lon > 20.0:

 

        utmzone = 35

 

    elif lat > 71.0 and utmzone == 36 and lon < 33.0:

 

        utmzone = 35

 

    elif lat > 71.0 and utmzone == 36 and lon > 32.0:

 

        utmzone = 37

 

        

 

    feature.setAttribute('UTM_ZONE', utmzone)

 

---

 

 

The output features will have a new attribute UTM_ZONE that contains the zone number. Special provisions are in place to handle the special cases around Norway and Svalbard (see the grid map at http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system).

 

 

David

Reply