How do I specify the Royal Observatory at Greenwich as a PyEphem observer? - astronomy

The PyEphem package provides the ability generate an Observer instance by providing the name of a city to the ephem.city() utility function, but seems to lack a way of specifying the Royal Observatory at Greenwich as a city.
Is there a name recognized by PyEphem that corresponds to the Royal Observatory at Greenwich? Is there a list somewhere of the cities that PyEphem recognizes?

You are correct — the Royal Greenwich Observatory is not a city and not available through the city() function. Instead, you will have to create its location manually:
gw = ephem.Observer()
gw.lat = '51:28:36.7'
(Note that you do not have to set the lon of the Observer because observers start out with zero as their latitude and longitude if you are not more specific.)

Related

check if a place is within an area (place_id)

I have a google maps place defined by their place_id s.
The place can refer to:
an address, eg 221B Baker St, Marylebone, London NW1 6XE, UK : ChIJFbp6NM8adkgRdOYUaV-EQlw
Or a general area eg London NW1, UK: ChIJoZM_S7EadkgR_T2MfOBVirE
I would like to know, using google maps API, whether a given address is inside the previous area or near the previously defined address (distance can be defined as a birth flight distance from the previous place).
You can use place IDs as origins and destinations in the Google Distance Matrix API. So, you can use your place ID as an origin and the address you want to test as the destination. Call the API to determine the distance. I think this was an update in 2017 maybe, see: https://developers.google.com/maps/documentation/distance-matrix/intro#RequestParameters

print google map route segments

Please tell me how to get a list of the last settlements in the itinerary? that's how it is done at this site
http://ati.su/Trace/default.aspx?EntityType=Trace&City1=3611&City5=1100&WithinCountry=false
(move the site in English via Google Translate), thank you very much for your attention
You may want to look to Google's documentation directly about Geocoded waypoints:
Details about the geocoding of every waypoint, as well as origin and
destination, can be found in the (JSON) geocoded_waypoints array.
These can be used to infer why the service would return unexpected or
no routes.
Elements in the geocoded_waypoints array correspond, by their
zero-based position, to the origin, the waypoints in the order they
are specified, and the destination. [...]
More specifically you would look into types:
types indicates the address type of the geocoding result used for
calculating directions. The following types are returned:
street_address indicates a precise street address.
route indicates a named route (such as "US 101").
intersection indicates a major intersection, usually of two major roads. political indicates a political entity. Usually, this type
indicates a polygon of some civil administration.
neighborhood indicates a named neighborhood
premise indicates a named location, usually a building or collection of buildings with a common name
subpremise indicates a first-order entity below a named location, usually a singular building within a collection of buildings with a
airport indicates an airport.
point_of_interest indicates a named point of interest. Typically, these "POI"s are prominent local entities that don't easily fit in
another category, such as "Empire State Building" or "Statue of
Liberty."
[...]
Among other types you want to highlight.
Legs also may help you (if there are no waypoints):
Each element in the legs array specifies a single leg of the journey
from the origin to the destination in the calculated route. For routes
that contain no waypoints, the route will consist of a single "leg,"
but for routes that define one or more waypoints, the route will
consist of one or more legs, corresponding to the specific legs of the
journey.
And each leg has a steps array:
Each element in the steps array defines a single step of the
calculated directions. A step is the most atomic unit of a direction's
route, containing a single step describing a specific, single
instruction on the journey. E.g. "Turn left at W. 4th St." The step
not only describes the instruction but also contains distance and
duration information relating to how this step relates to the
following step. For example, a step denoted as "Merge onto I-80 West"
may contain a duration of "37 miles" and "40 minutes," indicating that
the next step is 37 miles/40 minutes from this step.
Where each step has:
start_location contains the location of the starting point of this
step, as a single set of lat and lng fields.
end_location contains the
location of the last point of this step, as a single set of lat and
lng fields.

Regions of England in Google Maps API

I have a list of latitude/longitude which point to some cities in England.
For each of these coordinates I want to get the region they belong to.
By region, I mean one of these: https://en.wikipedia.org/wiki/Regions_of_England
For instance: For coordinates (53.38112, -1.47008), ie. Sheffield, I need to find Yorkshire and the Humber.
To achieve this, I tried to use Google Reverse Geocoding API:
https://maps.googleapis.com/maps/api/geocode/json?latlng=53.38112,-1.47008&key=
Google then tells me that:
country is United Kingdom
administrative_area_level_1 is England, which is a State (or kind of)
administrative_area_level_2 is South Yorkshire, which is a County
administrative_area_level_3 is Sheffield District, which is a District
So Google returns me the correct State, County and District. However, Region is missing.
Is there any way to obtain it?
Looking at the documentation I don't think the Google API returns such information.
An alternative way to get round this would be to build a list of which counties belong in which of the 9 regions and then look up the region based on the county name. Obviously, this would be a bit of work on your part putting all the county names into a list.
While this doesn't directly answer your query, you could use a set of polygons which trace the regions and a point in polygon algorithm (this example is in PHP but the algorithm exists in many languages) which would allow you to check which of the regions any latitude and longitude is in

Is there a numeric road identifier in google maps?

I'm looking for a way to identify roads or streets on google maps.
I don't need the road name, just an identifier for a road. And I don't really care if GPS coordinate is really on the road as long as the results are consistent.
I need this in order to determine if two GPS coordinates are on the same road.
Now I know I can compare the road name between the two coordinates using geocoder but In some cases the road name is null, and I actually don't care about the name itself.
Is there any road ID that I can get using a geocoder ?
What do you mean by the 'same road'?
A road can have many different names and designations at the same time and over its length.
Consider Route 66 do you want to be considered to be on the same road if you are on the same road if your two locations are on route 66 near Los Angeles and Chicago or is it a series of different roads as wends its way through the cities en-route?
Should a road have a different id if has an arbitrary name change as it goes round a bend or crosses from one town to the next?

How to map google Geocoding API results to simple City, Region, Country

I have some markers on a map and when the user click them I use the google geocoder to get the address information. The issue is the format that Google returns this data. I want to display the address in a consistent format such as
Vancouver, British Columbia, Canada
Seattle, Washington, United States
Sydney, New South Wales, Australia
does any one know a simple way to parse this data so I end up with some nice simple json like
{"city":"Vancouver", "region":"British Columbia", "country":"Canada"}
Thanks.
Oh man, the days when I thought political geography was this simple were sweeter days. If Google could return data like this, they surely would. Instead you get a mess of locality, sublocality, administrative_area_level_*, country, etc.
To illustrate this, consider the following:
http://maps.googleapis.com/maps/api/geocode/json?address=11215&sensor=false
http://maps.googleapis.com/maps/api/geocode/json?address=10010&sensor=false
For Manhattan, you're in okay shape. You get the borough (Manhattan), the city (New York), the county (New York), and the state (New York). For Brooklyn, things aren't so clean. You get the borough (Brooklyn), the county (Kings), and the state (New York).
Now if you go a little ways out onto Long Island, you get more fun:
http://maps.googleapis.com/maps/api/geocode/json?address=40.723464,%20-73.716282&sensor=false
In this case you get the village (Floral Park), the town (Hempstead), the county (Nassau), and the state (New York), but everything is kind of muddled up.
This is the variation within 20 miles in one state. If you move out of that, you can count on even less. In the UK, what most of what we'd want to see as London, will be some smaller borough of Greater London.
Google provides a deep and rich taxonomy to deal with this variation, but you will still need to apply your own rules to make sense of it (often at the state by state and country by country level)