NOTE: This article is 3 years or older so its information may no longer be relevant. Read on at your own discretion! Comments for this article have automatically been locked, refer to the FAQ
for more details.
This is a short example on how to change unit type
for Yahoo Weather YQL
query. This may be an overlooked bit of information but is covered quite well in the Yahoo! Weather Documentation
. Mind you this is the RSS
feed documentation but since YQL
uses this feed as a backend service, you can pass the same parameters into it as you would if you were using the RSS
feed directly. This is done using a feature called remote filters
Here's what the documentation states:
The optional u (units) parameter indicates the degree units for the weather forecast. By default, Yahoo! Weather returns temperature information in degrees Fahrenheit. Use the u parameter to explicitly specify the degree units in Fahrenheit (f) or Celsius (c). The units parameter is case sensitive. For example, to get the weather forecast in Sunnyvale, CA in Celsius:
Note that choosing Celsius degree units changes all the weather units to metric, for example, wind speed will be reported as kilometers per hour and barometric pressure as millibars.
That's great! So lets see how it behaves. I used the following query to test this (here's a YQL Console link to it
Note that the units information is returned in Metric units
When I change the 'u'
parameter to 'f'
, units are returned in Imperial
So there you go! Quite easy to do. Here's exactly what you get when you change the unit type
Set to 'c'
- Distance - kilometres
- Speed - kilometres per hour
- Pressure - millibars
- Temperature - degrees Celsius
Set to 'f'
- Distance - miles
- Speed - miles per hour
- Pressure - pounds per square inch
- Temperature - degrees Fahrenheit
A quick disclaimer...
Although I put in a great effort into researching all the topics I cover, mistakes can happen.
If you spot something out of place, please do let me know.
All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle).
Use of any information contained in this blog post/article is subject to this disclaimer
Other posts you may like...