Reverse Geocode With Administrative Boundaries.
- Get a shape file of administrative boundaries.
Dear Sir of Madam, We are a supplier of geomarketing data. Amongst others we also offer data for Taiwan. For one of our…data.gov.tw
2. Read the .shp file into a list of geojson.
sh = fiona.open('your_shape_file.shp')
3. Transform the coordinates to what you want.
4. Sample some points inside and outside the administrative boundaries.
from shapely.geometry import shape #to read geojson
#get 1 administrative boundary for example
ab = sh
poly = shape(ab['geometry'])
pts_inside = poly.buffer( -0.0001)
pts_outside = poly.buffer(0.0001)
5. Build a KDTree from points inside and outside of the boundaries.
(Thinks to Bob Haffner.)
I was recently working on a location based analysis with a client where we had a few records with invalid zipcodes. We…medium.com
6. As a result, any point can be reverse geocode to , in this case, 7 thousands of administrations in nano second.