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", ...

Get Mastering Geospatial Analysis with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.