How to request polygons from Google Maps? - google-maps

I am interested in an analogue of http://wiki.openstreetmap.org/wiki/Nominatim
I.e. to be able to make request and get some kind of polygon coordinates:
"geojson":{"type":"Polygon","coordinates":[[[-87.464761,44.600998],[-87.459755,44.599569],[-87.459745,44.601012],[-87.463143,44.601],[-87.464761,44.600998]]]}
Nominatim is good, but it lacks of some data (I am interested in data about cities and counties of Canada). For example, Google Map knows about the Ontario districts and highlights them, but OpenStreetMap - does not. As well as for some cities - where OpenStreetMap shows a dot, Google Maps shows full polygon.
Can it be done with Google Maps?
Other alternatives will work as well.

Yes, it can be done via GMaps API: https://gis.stackexchange.com/questions/43292/how-to-geocode-an-address-to-a-polygon
But be also aware of the legal restriction of the API and the commercial dataset, esp. if you want to use it regularly or for bulk processing: http://www.google.com/help/legalnotices_maps.html
I would also consider to help OSM to improve the dataset. This can be done by contacting the local community and offering help to ask for official public datasources. Esp. in the case of political boundaries, there is no way to get this material on the ground: http://wiki.openstreetmap.org/wiki/Canada

Related

Google Autocomplete Polygon as GeoJson

I'm trying to find in the Google Maps documentation a way to search for a place and get it's GeoJson polygon but I got no luck finding something like that.
My goal is to create a search bar to search places and then send the geojson polygon to our back-end. I don't want to draw it on a map or anything front-related.
Nominatim is doing exactly what I want but Nominatim policy is very restricted so before I go for an alternative, I wanted to check if Google Maps could provide the same (especially since searching for a country on Google Maps retrieve the polygon and draw it on the map).
Thanks for your help !
Unfortunately Google Maps APIs don't expose any polygons data of geographic features. You can see very old feature request in the Google issue tracker to add this functionality, however it looks like Google didn't set high priority on this task:
https://issuetracker.google.com/issues/35816953
Feel free to star the public feature request to express your interest and subscribe to further updates from Google.
You should get polygons from other sources.

How google get polygon data for locality in a city

I have seen google showing polygon lines for locality in a map. eg: https://www.google.co.in/maps/place/Koramangala,+Bengaluru,+Karnataka/#12.9354922,77.6146828,14z/data=!3m1!4b1!4m5!3m4!1s0x3bae144ed898fc2d:0x1681f38e8c00ae56!8m2!3d12.9279232!4d77.6271078
I wanted to know how google gets this data. Do they use any kind of mapping of images to the government data available in the countries in the world. I dont think all the countries provide data (lats, longs) at such granular level.
Right now this feature is unavailable for Google Maps API. But there is a feature request on Google's Issue Tracker that you can star and comment on.
Here's the link:
https://issuetracker.google.com/35816953
There are workarounds for this though where you get the data elsewhere and draw the polygons yourself.
Here's the link to that:
Google Maps how to Show city or an Area outline

Open Street Maps or Google API for extracting all house locations in a City?

I am working on mapping a city like represented in the real world. So how do I map the exact locations of houses and other key buildings ?. Should I work with reverse Geocoding provided by Google or extract and manipulate raw information from OSM.
You can't to that with the google maps geocoding API, without violating the terms of use, ragarding to chapter 10.5 Intellectual Property Restrictions, paragraph (c) and (e). This solution is very accurate but sadly there is no way to use it outside a google maps app.
The second way is to do it with OpenStreetMap. But be carefull ! OSM is a volunteered geographic map/database, with no guarantee for complete data. In a famous city there will be no problem! But if you want to get the houses in a little hamalayan village you will find no houses/data. But the simplest approach to get OSM data you may take use of the overpass API. You also can use the overpass API via the userinterface overpass turbo. Overpass turbo should be the approach of your choice, because there you are able to beck for existing houses/data parallel on a map.
With this snippet you get all buildings inside a polygon:
way(poly:"50.7 7.1 50.7 7.2 50.75 7.15")["building"];
(._;>;);
out body;

Get type of terrain by coordinate

I'm looking for a solution to be able determine landscape type by a given coordinate, for example check if current position is water/forest/town/road and so on. I found google.maps.MapTypeStyleElementType object specification in the Google Maps specification, but not sure if it could help me or not.
Probably, there are some another Maps API with such functioality? Or maybe I should refer to the different types of offline maps?
Nope, the link you send is just for styling the proper features, not to tell which feature is at a given coordinate. If you are interested in landscape, then Corine Land Cover is the thing you are looking for. It describes the types of biotops like forest, water, but also land use - meadow, field, buildings etc. However, I don't know if there is such an online service where you could query particular coordinates. Other solution for you would be to import these GIS layers (they are freely available) to your own gis map server. Maybe this is partially solved as there are e.g. projects how to incorporate these into openstreetmap.
Well not quite, but you could get close to what you're looking for by using the Google Reverse Geocoder and the Google Places API
Google Reverse Geocoding
http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding
If you send the service a geocode it will send back an address type and/or one of several adress components http://code.google.com/apis/maps/documentation/geocoding/#Types
Google Places API
http://code.google.com/apis/maps/documentation/places/
You could use the Google places API to search for for what's near. If the geocode is in the middle of the lake, the Places API may return something like "Lake Michigan" and then you'd know the terrain obviously.

How to find a closest street

I'm reading through Google Maps API documentation and I wonder if such a think is possible:
I specify the point (by coords)
I search for all roads, and junctions around the node (say in 1km radius)
I get parameters for the streets around (polyline coords)
Is it reachable, or google do not share that data?
Thanks in advance
Rafal
I can image writing up a little script that generates a bunch of random points within a 1km radius and then performs directions services via Google Maps API to obtain all possible routes and thus streets within a 1km radius. However, this is problematic since it is kinda against the Google Maps TOS of displaying this information only on a map within a website and not extracting data for you personal use as this would be.
A better approach would be looking into utilizing Open Street Map data where you can download street data from a specific viewport. If buying street network data is an option, you can go to a commercial outlet such as NAVTEQ or PTV which post-processes NAVTEQ data to a format for use in the transport modeling software package you mention on your blog.