Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Negative Buffer Used to Avoid Selecting More Than 1 Cell
sp_filter = filters.intersects(
Geometry(row[1].SHAPE).buffer(-.1),
self.grid_wkid
)
if not indicator_url:
df_current = SpatialDataFrame(
columns=field_schema.get(indicator),
geometry=[Geometry(json.loads(row[1].SHAPE.JSON))]
)
created = True
else:
# Negative Buffer to Select a Single Grid Cell
sp_filter = filters.intersects(
Geometry(row[1].SHAPE).buffer(-.1),
self.grid_wkid
)
df_current = data_fl.query(geometry_filter=sp_filter,
return_all_records=self.return_all_records).df
# Set The First Instance
if idx == 0:
# Check If Cell Found in Target Indicator Layer
if df_current.empty:
# Use Grid SDF Row Geom to Insert Empty Record for Target Indicator
data_fl.edit_features(adds=[
{
'attributes': {},
def set_features(self):
df_list = []
for idx, row in enumerate(self.grid_sdf.iterrows()):#self.grid_sdf.iterrows()):
geom = Geometry(row[1].SHAPE)
print(idx)
sp_filter = filters.intersects(geom, self.grid_wkid)
data_fl = FeatureLayer(url=self.feat_url, gis=self.gis_conn)
## Change return all records to True
df_list.append(
data_fl.query(geometry_filter=sp_filter,
return_all_records=self.return_all_records).df
)
self.features = df_list