[GIS] How to get lat/long of all adresses inside a polygon in google map

google earthgoogle mapsgoogle-maps-apikml

I have several polygon shapes inside a City in Germany. I need to generate Point data of houses inside those Polygons. It is very time consuming to add all the building Locations manually. I am wondering, if it is possible to extract the Point for all address somehow from Google maps as XML or kml Format.

For your Kind information, I do not have any Point data. I need to generate it somehow using Google map or Google earth from geocoded address. That is now the main challenge for me.

Best Answer

You can generate a mesh of, for example, 0.001 degrees on each side, and make a reverse geocoding for every point. The google geocoder service would answer with N possible addresses.

Each reverse geocoding request would have the following structure

var latlng = new google.maps.LatLng(lat, lng);
  geocoder.geocode({'latLng': latlng}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
      if (results[1]) {
         map.setZoom(11);
        marker = new google.maps.Marker({
            position: latlng,
            map: map
        });
        infowindow.setContent(results[1].formatted_address);
        infowindow.open(map, marker);
        } else {
           alert('No results found');
        }
    } else {
        alert('Geocoder failed due to: ' + status);
    }
});

Of course, this won't be an exhaustive directory of all addresses, but it will get you a nice sample of addresses.

Btw, the geocoder has a request limit for each day, and it's also throttled on its requests per seconds capacity.