Counties

Similar to the State database table, this will retrieve all of the county data. It accepts a geometry parameter to decide if it will return the geometry of each county:

@app.route('/nba/api/v0.1/county', methods=['GET'])
def get_counties():
counties = session.query(County).all()
geoms = {county.id:smapping(to_shape(county.geom)) for county in counties}
if 'geometry' in request.args.keys():
data = [{"type": "Feature",
"properties":{"name":county.name, "state":county.state.name},
"geometry":{"type":"MultiPolygon",
"coordinates":[shapely.geometry.geo.mapping(to_shape(state.geom)["coordinates"]]},
} for county in counties]
else:
data = [{"type": "Feature",
"properties":{"name":county.name, "state":county.state.name},
"geometry":{"type":"MultiPolygon",
"coordinates":["Truncated"]},
} for county in counties]
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