How to fetch the country name based on latitude and longitude in codename one..? - gps

I am trying to retrieve the country name using Lat and Long I fetched using locationmanager in codename one... How to get country, state, city, zip based on these parameters..??

You need to use a webservice that will translate location data to location meta data e.g. this one https://www.codenameone.com/blog/dynamic-autocomplete.html
Notice that the sample above uses a different feature of that webservice but the same concept applies.

Related

API to List of all Suburbs in a City or country

Is there an API i can use to fetch all cities in a Country or country state using its name
e.g https://api.domain/?q=suburbs&country=US.
I need results shown like these except that their documentation API only shows limited results as compared to the actual data returned here

What is the industry standard way to store country / state / city in a database of web APP?

For country and state, there are ISO numbers. With City, there is not.
Method 1:
Store in one column:
[Country ISO]-[State ISO]-[City Name]
Method 2:
Store in 3 separate columns.
Also, how to handle city names if there is no unique identifier?
First and foremost, three separate columns to keep your data. If you want to create a unique identifier, the easiest way would be giving a random 3-10 digit code depending on the size of your data set. However, I would suggest concatenating [country-code]-[state-code]-[code] if you have a small data set and if you want human readability to a certain point. code can be several things. Here are some ideas:
of course a random id or even a database row id
licence plate number/code if there is for a city
phone area code of the city or the code of the center
same logic may apply to zip codes
combination of latitude and longitude of the city center up to certain degree
Here are also more references that can be used:
ISO 3166 is a country codes. In there you can find codes for states or cities depending on the country.
As mentioned IATA has both Airport and City codes list but they are hard to obtain.
UN Location list is a good mention but it can be difficult to gather the levels of differentiation, like the airport code or city code or a borough code can be on the same list, but eventually the UN/LOCODE must be unique. (Airport codes are used for ICAO, similar to IATA but not the same)
there are several data sets out there like OpenTravelData or GeoNames that can be used for start but may require digging and converting. They provide unique codes for locations. And many others can be found.
Bonus:
I would suggest checking Schema.org's City Schema and other Place Schemas for a conscious setup.

How do I get census data of a particular zip code?

https://api.census.gov/data/2013/acs/acs5?get=NAME,B01001_001E&for=place:51000&in=state:36&key=key123
That is the query I attempted to use. I only get the data for New York City population, but I want the population of that zip code, and if possible query further onto the data of that zip code. I obtained the "place" using ZTCA5 to place chart they provided.
thanks.

query maxmind mmdb for country when given a city

I'm looking to get a city to country mapping without an IP address
I have access to these files on my box:
GeoIP2Country.mmdb
GeoIPCountry.dat
GeoIP2City.mmdb
GeoIPCity.dat
GeoIP2ISP.mmdb
GeoIP2Connections.mmdb
Normally the way I would use this is GeoIP2Country.country(cip).country.name and it would return a country name for the IP I feed it.
In my use case I want to provide it with a city name and have it return a country name. Since all the data is in there this would save me a lot of time. Is it possible to query mmdb (no idea how to do this) then convert that to a dataframe so I can just have a df of country to city mapping or vise versa?
based on this :Query by city name on geolite2 .mmdb file (JAVA) I cant do what I wnated to.
BUT there is also a country_code.csv I think thats offered by maxmind which does what I need in conjunction with some other non mmdb files.

How to access weather data from all the stations in one country using openweathermap?

I am using Alteryx to extract weather data for a handful of cities and it works great. I'd like to expand this to able to download data for all weather stations in the UK. At the moment I am specifying which cities I want, e.g. London / Manchester.
Is there a way of specifying in the api call to download all stations in 'GB' or 'UK'?
Ideally I'd like to do this in one call rather than listing all locations which will be very laborious
Get a list of stations or cities that you want to retrieve weather data from. I found some good sources from openweather here: http://bulk.openweathermap.org/sample/
Then build a url request using the list of id's above that retrieves specific weather information. Using an id for the weather station in Cairns, id=2172797, the url ends up looking like:
http://api.openweathermap.org/data/2.5/weather?id=2172797&appid=843798874aac0ef138e6f77c72f3af80
Note that this url will return an error because this isn't a real appid. If you replace the appid with your own, this url will give you data for that station.
Putting this process into Alteryx lets you put the list of station id's together with the url and the appid to make many calls into openweather and then process all of the data together. I could not find information from the API on rate limits, so be conscious of how many requests you are posting to the service.
There is an example of this process here: https://www.dropbox.com/s/yoppbx3bw0p4rug/Get%20individual%20stations.yxzp?dl=0
Keep in mind that you have to update the Appid in the text input tool within this sample as well.