Select to view content in your preferred language

Script to extract UTM Zone using Range and Meridian information

1789
9
08-09-2012 09:39 AM
IreneEgbulefu
Deactivated User
Hi Everyone, I am looking for a phython or php script that will accept the Range and Meridian values of a location and use it to identify the UTM zone.

I have a table that comprises of Easting, Northing, Range and Meridian but im missing the UTM zones of these points. I am able to manually identify the UTM zone knowing the range and Meridian of the location. I wish to automate this by using a python script that will scan in these parameters as variables and extract the UTM zones based on the parameters.

Can someone please help me out! It will really be exciting to achieve this as i need it move ahead with my job, its so clumsy having to go through thousands of point data to this manually.
Thanks for your most valued input!
Tags (2)
0 Kudos
9 Replies
GraemeBrowning
Frequent Contributor
I'm not familiar with type of data Irene is looking at but just noticed that the same question is posted (with no accepted answer) at Stack Exchange GIS so that is somewhere else to look for ideas on how to do this.

- Graeme
0 Kudos
curtvprice
MVP Alum
Hi Everyone, I am looking for a python or php script that will accept the Range and Meridian values of a location and use it to identify the UTM zone.


I'm not familiar with what you mean by "range" unless you mean the range of a single zone, say -72 to -78 longitude. The meridian is of course the center of the zone, say, -74. UTM is nicely described in its wikipedia article,  as follows:

The UTM system divides the surface of Earth between 80°S and 84°N latitude into 60 zones, each 6° of longitude in width. Zone 1 covers longitude 180° to 174° W; zone numbering increases eastward to zone 60 that covers longitude 174 to 180 East.


So -- you know the zone's central meridian, you can calculate the zone like this:

zone = int((( merid + 180 ) % 360 ) / 6 ) + 1


For a value of merid = -75 this yields a zone value of 18.

Here's python interactive code to test it:

>>> for merid in range(-177,183,6):
...   print merid, merid-3,merid+3,int(((merid + 180) % 360) / 6) + 1
... 
-177 -180 -174 1
-171 -174 -168 2
-165 -168 -162 3


Here's another explanation, that uses different (but I'm assuming equivalent) integer math.
http://www.resurgentsoftware.com/GeoMag/utm_coordinates.htm
0 Kudos
ChristopherThompson
Frequent Contributor
Range and Meridian

Your terminology is a little confusing - both those terms seem like they relate to Public Land Survey System (Township-Range-section) for describing legal locations, but refer to different attributes of that nomenclature.  It would help if you could clarify these terms - for instance, a PLSS township/range/section is described according to a specific Baseline and Meridian - do you mean Baseline here instead of Range or do you really mean the Range (denoted usually as a value E or W of a the Meridian.. ).  Also, Meridian in this context is not the same as the Central Meridian as a UTM zone, so a clearer example of these terms is important.  PLSS Meridian and baselines are descriptive rather than expressed as degrees of longitude - for instance the PLSS for Arizona references the 'Gila and Salt River Base Line and Meridian'.  Perhaps an example of the data you have would be useful as well.
0 Kudos
IreneEgbulefu
Deactivated User
I posted the question there and i am yet to get the right anwser.
Thanks for your observation

I'm not familiar with type of data Irene is looking at but just noticed that the same question is posted (with no accepted answer) at Stack Exchange GIS so that is somewhere else to look for ideas on how to do this.

- Graeme
0 Kudos
IreneEgbulefu
Deactivated User
Hi Curtvprice,
I tried the script but it is giving me a parsing error. I do not quite understand the parameters you are using here, I mean which of the numbers are range and meridian.
Here are some sample data i have


                                                (All Range values are 1,2,3,4,5,.........30)
  Meridian = W2M          ;          Range =  1    to   30

  Meridian = W3M         ;           Range  = 1    to   30

Meridian = W4M         ;           Range =  1   to   30

Meridian = W5M        ;            Range =  1   to   30


I would like to use a python script to deduce the UTM zones for these meridian and range values.
Thanks for your help

I'm not familiar with what you mean by "range" unless you mean the range of a single zone, say -72 to -78 longitude. The meridian is of course the center of the zone, say, -74. UTM is nicely described in its wikipedia article,  as follows:



So -- you know the zone's central meridian, you can calculate the zone like this:

zone = int((( merid + 180 ) % 360 ) / 6 ) + 1


For a value of merid = -75 this yields a zone value of 18.

Here's python interactive code to test it:

>>> for merid in range(-177,183,6):
...   print merid, merid-3,merid+3,int(((merid + 180) % 360) / 6) + 1
... 
-177 -180 -174 1
-171 -174 -168 2
-165 -168 -162 3


Here's another explanation, that uses different (but I'm assuming equivalent) integer math.
http://www.resurgentsoftware.com/GeoMag/utm_coordinates.htm
0 Kudos
IreneEgbulefu
Deactivated User
Your terminology is a little confusing - both those terms seem like they relate to Public Land Survey System (Township-Range-section) for describing legal locations, but refer to different attributes of that nomenclature.  It would help if you could clarify these terms - for instance, a PLSS township/range/section is described according to a specific Baseline and Meridian - do you mean Baseline here instead of Range or do you really mean the Range (denoted usually as a value E or W of a the Meridian.. ).  Also, Meridian in this context is not the same as the Central Meridian as a UTM zone, so a clearer example of these terms is important.  PLSS Meridian and baselines are descriptive rather than expressed as degrees of longitude - for instance the PLSS for Arizona references the 'Gila and Salt River Base Line and Meridian'.  Perhaps an example of the data you have would be useful as well.


Hi Thompson,

Sorry if youre somewhat confused about my data, but i dont think your understanding of it is far from being correct.
The data describes a legal location and it is similar to the public land survey system that is used in the United States, but in Canada we use what is known as Dominion Land Survey system (Western Canada).
So the DLS identifies location by their Township-Range-Secion and Meridian. Thus my data are basically survey data and the description is given in DLS format. Currently our job areas fall within the West Meridian 1 written as (W1M) and West meridian 7(W7M). This is not the same thing as Central Meridian. The central Meridian is the longest line of  longitude that runs from North to South forming the axis of symmetry
0 Kudos
ChristopherThompson
Frequent Contributor
The data you show make me think you are in Canada and are refering to the Dominion Land Survey system there.  The notation W2M seems like it would be a reference to the 2nd Meridian which is 102° west as described in this page: http://en.wikipedia.org/wiki/Dominion_Land_Survey

Do you have a featureclass (shapefile or otherwise) that depicts the Canadian DLS?   If so here are the steps you could take:
1) form a SQL query statement from your data (for example: "where "Meridian" = 'W2m' and "Range" = 😎
2) use that query statement in a python SelectByAttributes tool to select from the DLS layer
3) Do a select by location using the Selection set in the DLS layer against a UTM Zone layer
4) query the selected value(s) from the UTM Zone layer to make a decision about what spatial reference to define for that point.

The difficulty here though is you might get 2 UTM zones this way, a range crosses a UTM zone - without the corresponding Township number that maybe difficult to sort out.
0 Kudos
IreneEgbulefu
Deactivated User
I'm not familiar with what you mean by "range" unless you mean the range of a single zone, say -72 to -78 longitude. The meridian is of course the center of the zone, say, -74. UTM is nicely described in its wikipedia article,  as follows:

So -- you know the zone's central meridian, you can calculate the zone like this:

zone = int((( merid + 180 ) % 360 ) / 6 ) + 1


For a value of merid = -75 this yields a zone value of 18.

Here's python interactive code to test it:

>>> for merid in range(-177,183,6):
...   print merid, merid-3,merid+3,int(((merid + 180) % 360) / 6) + 1
... 
-177 -180 -174 1
-171 -174 -168 2
-165 -168 -162 3


Here's another explanation, that uses different (but I'm assuming equivalent) integer math.
http://www.resurgentsoftware.com/GeoMag/utm_coordinates.htm



Hi Curtprv,
I ran the script above but it gave me a wrong answer for the supplied  meridian.
For instance in  my code below, I tried to see what the equation will return as the zone for meridian 2 but it gave me Zone 31 instead of  Zone 13. If calculated manually, the zone is determined by two parameters - the DLS range and the Meridian value which i found to be  missing in your equation. Please can you take a look once more at the equation.
merid = 2
zone = int((( merid+180) % 360) / 6) + 1
print zone
0 Kudos
curtvprice
MVP Alum
the zone is determined by two parameters - the DLS range and the Meridian value which i found to be missing in your equation. Please can you take a look once more at the equation.


I'm sorry, you are clearly not talking about UTM zones, which are 60 Transfers Mercator zones (really 120 if you can north and south) defined merely by zone numbers that are basically a lookup to one of 60 a central meridians. Sounds to me like the DLS zones is what you are working with [post=224323]as Christopher Thompson suggested above [/post]
0 Kudos