2

Hi frens I am using geopy to calculate the latitude and longitude. Now I want to get the list of areas given distance from a zipcode.How to get that?

RaviKiran
  • 753
  • 1
  • 6
  • 13

2 Answers2

0

Well, as I can see, geopy doesn't have any built-in capability to get a list of areas around some coordinates.

But you can use a workaround. Take your geocode and calculate coordinates (latitue and longitude). Then imagine a grid on the map with a cell size equal to area of the smallest one you need to find around your location.

Use geopy to get an area name belonging to the each cell corner of your grid. Is that ok for you? It will get you some kind of approximation because a grid is not a circle and you may miss some small areas. But I think in most cases the solution will work fine.

Vladislav Rastrusny
  • 29,378
  • 23
  • 95
  • 156
0

It is much easier to locate zipcodes inside a rectangle than in a circle so I would recommend that you approximate your problem by looking for zipcodes inside a given rectangle.

Here are answers to the question of how to get list of zipcodes in given polygone: Find zipcodes inside polygon shape using google maps api

Summary

You need geometry for each zipcode. Once you have that you need to be able to query it using database that supports geoquery. One such database is Google's Fusion Table and there is already a geometry data table for zipcodes available here: https://www.google.com/fusiontables/DataSource?docid=1AxB511DayCdtmyBuYOIPHIe_WM9iG87Q3jKh6EQ#rows:id=1

Here's the sample query for Fusion Table data.

Another approach is server side code using PHP and CSV data. Here's live demo: http://daim.snm.ku.dk/demo/zip/. The page also has download for code.

If you use any of above technique please make sure to upvote answers of original authors :).

Community
  • 1
  • 1
Shital Shah
  • 63,284
  • 17
  • 238
  • 185