Skip to content

Instantly share code, notes, and snippets.

@LimaGuilherme
Last active October 10, 2018 01:25
Show Gist options
  • Select an option

  • Save LimaGuilherme/00e14f5a4e727d5e48459c4a9bba06db to your computer and use it in GitHub Desktop.

Select an option

Save LimaGuilherme/00e14f5a4e727d5e48459c4a9bba06db to your computer and use it in GitHub Desktop.
first_version_of_index_country_polygons
def index_country_polygons(path_to_file):
schema = {
'geometry': 'Polygon',
}
with fiona.open('{}'.format(path_to_file), 'r',
'ESRI Shapefile', schema) as polygon_feature:
for geometry in polygon_feature:
polygon = shape(geometry['geometry'])
country = geometry['properties']['NM_MUNICIP']
state = find_in_dict(int(geometry['properties']['CD_GEOCMU'][:2]))
Country.index_country(polygon=polygon.wkt,
country=country,
state=state)
print('INDEXING: {}, {}'.format(country, state))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment