OpenStreetMap 로고 OpenStreetMap

Degree widths on different latitudes

Mursti님이 English로 2009년 9월 9일에 게시함.

I like statistics. Most OSMians seem to prefer maps but I like to see a number :)

How many percents of street kilometers in Helsinki have lit -tag? How many kilometers of lit ways in Helsinki does OSM have? Does this percentage vary between suburbs? Which suburb needs most work (has smallest percentage)? ...

In order to answer these questions I need to be able to calculate the length of a way. In order to do that I need to know how many meters is a (for instance) 0.00345 degrees latitudial and 0.00634 longitudial difference. How can I find that out?

Wikipedia to the rescue! http://en.wikipedia.org/wiki/Geographical_coordinates has a handy formula for calculating longidutial degrees width in different latitudes. After some head scratching I was able to hammer down this peace of python:

def lon_length(latitude):

PR=6356752.3142 # Polar radius
ER=6378137.0 # Equtorial radius
lat=math.radians(latitude)
# http://en.wikipedia.org/wiki/Geographic_coordinate
return math.pi*(\
math.cos(lat)*math.sqrt(((math.pow(ER,4))*(math.pow(math.cos(lat),2))+\
(math.pow(PR,4))*(math.pow(math.sin(lat),2)))/\
(math.pow((ER*math.cos(lat)),2)+\
pow((PR*math.sin(lat)),2))))/180

After this and some other easier and less interesting functions I now have means to measure way lengths :) Hopefully this proves useful.

이메일 아이콘 Bluesky 아이콘 Facebook 아이콘 LinkedIn 아이콘 마스토돈 아이콘 텔레그램 아이콘 X 아이콘

토론

댓글을 남기려면 로그인하세요