Last active
October 10, 2018 01:25
-
-
Save LimaGuilherme/00e14f5a4e727d5e48459c4a9bba06db to your computer and use it in GitHub Desktop.
first_version_of_index_country_polygons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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