Skip to content

Instantly share code, notes, and snippets.

@ustroetz
ustroetz / service.py
Last active November 5, 2023 21:30
Lambda function to trigger dependent AWS Batch jobs
def handler(event, context):
client = boto3.client('batch', 'us-east-1')
analyzer_job = client.submit_job(
jobName='ma-analyzer',
jobQueue='ma',
jobDefinition='ma-analyzer:1',
containerOverrides={
'command': ['python', 'service.py']
})
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
connection_routes_gdf = gpd.sjoin(
routes_segments_gdf, routes_gdf, how='left', op='within').dissolve(by='id', aggfunc='sum')
connection_routes_gdf.to_file(
'connection_routes.geojson', driver='GeoJSON')
routes_segments = routes_gdf.unary_union
routes_segments_gdf = gpd.GeoDataFrame.from_features([{
"type": "Feature",
"properties": {"id": count},
"geometry": mapping(geometry)
} for id, geometry in enumerate(routes_segments)])
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
with open('connection_lines.geojson') as connection_lines_file:
connection_lines = json.loads(connection_lines_file.read())
route_features = []
for line_feature in connection_lines['features']:
origin = {
'type': 'Feature',
'geometry': {
'type': 'Point',
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.