You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
drop_table_query="""drop table if exists parcels1"""
116
+
conn.execute(drop_table_query)
117
+
118
+
create_table_query="""create table parcels1 as select TAZ, psrc_id, st_unaryunion(st_collect(geometry)) as geometry from parcels WHERE psrc_id in %s group by TAZ"""%parcel_id_string
119
+
conn.execute(create_table_query)
120
+
121
+
getResultsQuery="""SELECT AsGeoJSON(geometry), psrc_id FROM parcels1"""
122
+
#print getResultsQuery
123
+
124
+
125
+
# fetch the results in form of a list of dictionaries
126
+
results=conn.execute(getResultsQuery).fetchall()
127
+
#print results
128
+
# create a new list which will store the single GeoJSON features
129
+
featureCollection= []
130
+
131
+
# iterate through the list of result dictionaries
132
+
forrowinresults:
133
+
134
+
# create a single GeoJSON geometry from the geometry column which already contains a GeoJSON string
135
+
geom=geojson.loads(row['AsGeoJSON(geometry)'])
136
+
137
+
# remove the geometry field from the current's row's dictionary
138
+
row.pop('AsGeoJSON(geometry)')
139
+
140
+
# create a new GeoJSON feature and pass the geometry columns as well as all remaining attributes which are stored in the row dictionary
# append the current feature to the list of all features
144
+
featureCollection.append(feature)
145
+
146
+
# when single features for each row from the database table are created, pass the list to the FeatureCollection constructor which will merge them together into one object
# append the current feature to the list of all features
151
+
printfeature
152
+
featureCollection.append(feature)
153
+
154
+
# when single features for each row from the database table are created, pass the list to the FeatureCollection constructor which will merge them together into one object
0 commit comments