How to get dimensions in original language - google-visualization

I'm trying to get something like the Google analytics dashboard but I have some troubles with the language of the result of my query.
When I get the result of my query, I get all the names in English but the geochart only understands the local names.
So when I get for example "Brittany" as a ga:Region, the geochart will not understand it and so won't show it on the map whereas "Bretagne" will. That's the same for all translations.
Do you have any idea of how I could have either the region in the original language or have the geochart understanding the english name of the region?

The Google Analytics API returns values only in English. Unfortunately you are going to have to translate them yourself.

Related

how to deal with different ways to write the same thing

I wanna know if Django has any module to deal with this problem.
I have multiple ways of writing the same city name in a Postgresql database that came from scraping different websites. The field "city name" could be "S. Diego" or "San Diego". My question is if I could have a module that could normalize always to "San Diego" in both situations and I could add some normalization when some new word appear like "S Diego", and maintain this workflow.
Thanks
You can use an API to normalize the data you have scraped. Yandex or Google have feature to return a possible list of the location names based on your search query. Get the most possible answer they returned and use it to map your input to the correct one. There are manual mapping features but I highly recommend one of the giants that solved the problem before us.

Country Codes API

I was able to construct a detailed spreadsheet from iso.org, by going through 10 different web pages, copying and pasting.
What I would like to do, is keep this list updated, and add/de-activate as countries appear, disappear or split.
I did a search, but could not find an API to retrieve the ISO codes (long name, 2-code, 3-code, numeric). Anyone aware of such an API?

Facebook graph api returning results in local language

I came across a funny yet disturbing issue today. I queried for cities to Facebook graph API through my browser and it returned correct results but then i hit the same service it returned same result but it translated one field(country_name) into my local language(Urdu).
I tried different access tokens and gems but result was same. Anyone has any idea how can i get results in English?
here's the api call : https://graph.facebook.com/v2.12/search?type=adgeolocation&location_types=city&q=new&country_code=US&region_key=3887&access_token=
here's a screenshot
I am not sure where you read about "country_code", but according to the docs it´s the "locale" parameter:
https://developers.facebook.com/docs/graph-api/using-graph-api
For example: locale=en_US
It was my language setting in which i had set "language i understand" to Urdu and didn't set "which languages do you not want automatically translated". By setting "which languages do ...." to "English" issue resolved but the funny thing is that, this issue only occurred when i called it in my Ruby on Rails application. Result was all in English when i hit same service through my browser or through graph API explorer.

Mapbox Geocoding language

The Mapbox API supports geocoding requests fine, but I always get the results in English. I'd like to be able to get results in a specific language.
For the Mapbox.js API, it's possible to display the map in a different language (by changing style), but I can't find a way to translate geocoding requests correctly.
For example, if I pass in the city 'Gent', I would expect to see that it's in province Oost-Vlaanderen and country België. However, I get 'Gent, Oost-Vlanderen, Belgium'.
This would be done using a request like: https://api.mapbox.com/geocoding/v5/mapbox.places/Gent.json?country=be&access_token=MYACCESSTOKEN
Is there a way to get the correctly translated result? Perhaps using a setting or extra parameter?
The localized names that I see in Streets-v8 (and likely in mapbox.places) are name_en, name_es, name_fr, name_ru, & name_zh.
This looks like you'll need to file a feature request with Mapbox, at least you may be able to have support for name_fr.
I like to use the Mapbox Command Line Interface to see the responses from the Mapbox querys. This particular query gives a response of "place_name": "Gent, Oost-Vlanderen, Belgium",
mapbox-cli> mapbox geocoding 'Gent' --country be
I also tried Ghent in the query, but still received English
The town shows as Ghent in the Mapbox language switch example.
Looks like a solution has been implemented!
Just pass in a language field on the initialization object like so:
var geocoder = new MapboxGeocoder({ language: 'es' }); //change lang to spanish
Got it from these docs: https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md#mapboxgeocoder

I need a sunrise/sunset webservice api

Anyone know of a good webservice or api that I can use to get the sunrise/sunset times in bulk? Every thing I have found so far only gives a day at a time or has a limitation on what dates can be used.
http://sunrise-sunset.org/api
It's free to use. Just needs a credit link back to the website.
It's not a web service, but this SO question has links to algorithms, so you can create a table or your own web service with all the dates you need.
I recently found this JavaScript library that performs calculation based on date and lat/lon coordinates. It seems to be very precise.
Link: https://github.com/mourner/suncalc
It is also available as NodeJs package through npm.
NASA has the calculation in nicely laid out JS. View the source of this page:
http://www.esrl.noaa.gov/gmd/grad/solcalc/
NOTE: I'm not a lawyer but I believe the US Government cannot copyright anything, hold patents, etc. so one should be able to copy as use as one needs.
This is a nice and free sunrise and sunset times API: http://sunrise-sunset.org/api
PHP has built in functions to calculate sunrise/sunset:
http://php.net/manual/en/function.date-sunrise.php
http://php.net/manual/en/function.date-sunset.php
Weather underground has this:
wunderground astronomy feature
Keys are free and they have a pretty generous policy for volume. Been using their weather actuals and forecast json forecast for about year, couldn't be happier.
EarthTools comes up first on google here at webservices sunrise sunset
The NASA one is cool, but the US Naval Observatory has one (below) that could actually pass for an API. If you want to make it useful beyond its intended purpose:
inspect the http headers to find out what parameters are being sent
parse the hell out of the response
It was a fun exercise. You should be able to send a location (long/lat or City/State) along with a year to obtain a list of sunrise and sunset times for an entire year (and other data as well).
http://aa.usno.navy.mil/data/docs/RS_OneYear.php
Go to this website > https://www.esrl.noaa.gov/gmd/grad/solcalc/
1. Set your location
Select your location. You can zoom in to your location and move the pin manually.
2. Verify your Location and Date
Scroll down to the 'Location' under the map and verify your location.
The date is automatically taken, if not set it manually.
3. Get the details
Click the button 'Create Sunrise/Sunset Tables for the Year'.
4. Output in a Table
New window opens and all the details are displayed as table.
Thanks to #noctonura for the link.
Let's go to http://www.earthtools.org/webservices.htm
It's free web service that provides Timezone and Sun times from Latitude/Longitude location.
There is a way to calculate the sunrise/sunset without the need of an API. Its mostly based on location. Sorry I dont have much more info.
Home page
Query url
Url syntax:
http://sunpath.azurewebsites.net/api/values/LAT/LON/ALT/TIMEZONE
You must replace LAT, LON, ALT and TIMEZONE with your data
.
JSON result:
{"zenith":55.365660255995422,"azimuth180":25.434155784212443,"azimuth":205.43415578421244,"incidence":55.365660255995422,"suntransit":12.423540739046871,"sunrise":6.9577562375305817,"sunset":17.899687249200021,"time":"2016-02-23T13:49:31.3816733Z"}
Or you can access online version of SPA.c algorithm:
Online query for SPA algorithm
Output is not in JSON format, but you can specify multiple times and get multiple results:
Date,Time,Top. azimuth angle (westward from S),Topocentric sun declination,Topocentric sun right ascension,Top. elevation angle (uncorrected)
2/23/2016,0:00:00,168.224314,-10.130760,335.659091,-57.643946
2/23/2016,1:00:00,-164.161551,-10.115560,335.699290,-57.227919
2/23/2016,2:00:00,-140.171655,-10.100376,335.739465,-51.963801
2/23/2016,3:00:00,-122.026618,-10.085209,335.779585,-43.529014
2/23/2016,4:00:00,-108.202194,-10.070054,335.819621,-33.425695
2/23/2016,5:00:00,-96.857772,-10.054907,335.859549,-22.544581
2/23/2016,6:00:00,-86.694509,-10.039764,335.899355,-11.406096
2/23/2016,7:00:00,-76.801678,-10.024618,335.939030,-0.376624
2/23/2016,8:00:00,-66.440121,-10.009464,335.978575,10.203398
2/23/2016,9:00:00,-54.907983,-9.994297,336.017999,19.930206