Getting a county by ID

After retrieving all counties using the get_counties function, the ID of a specific county can be passed to this function. Using session.query.(County).get(county_id) allows for the retrieval of the county of interest:

@app.route('/nba/api/v0.1/county/<int:county_id>', methods=['GET'])
def get_county(county_id):
county = session.query(County).get(county_id)
shp = to_shape(county.geom)
geojson = shapely.geometry.geo.mapping(shp)
data = [{"type": "Feature",
"properties":{"name":county.name, "state":county.state.name},
"geometry":{"type":"MultiPolygon",
"coordinates":[geojson]},
}]
return jsonify({"type": "FeatureCollection","features":data})
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset