Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from shapely.geometry import mapping, Polygon
import fiona
import csv
# Carrefour GZ
gz = Polygon([])
# chengdu 1
cd1 = Polygon([])
# chengdu 2
cd2 = Polygon([])
# kum
km = Polygon([])
hah = ['grid', 'field1']
pro = {i: 'str' if i == 'grid' else 'int' for i in hah}
schema = {
'geometry': 'Polygon',
'properties': pro,
with'four.shp', 'w', 'ESRI Shapefile', schema) as c, open("file_path", 'r', encoding='utf-8-sig') as f:
r = csv.DictReader(f)
for i in r:
grid = i['grid']
if grid == 'Guangzhou':
poly = gz
if grid == 'Chengdu_1':
poly = cd1
if grid == 'Chengdu_2':
poly = cd2
if grid == 'Kunming':
poly = km
'geometry': mapping(poly),
'properties': {**i},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.