Geohunter.util¶
geohunter.util
This module implements further operations for analyzing OpenStreetMap data.
-
geohunter.util.
contour_geojson
(y, lonv, latv, cmin, cmax)¶ Supports plotting the result of kde_interpolation.
-
geohunter.util.
kde_interpolation
(poi, bw='scott', grid=None, resolution=1, area=None, return_contour_geojson=False)¶ Applies kernel density estimation to a set points-of-interest measuring the density estimation on a grid of places (arbitrary points regularly spaced).
Parameters: - poi (GeoDataFrame.) – Corresponds to input data.
- bw ('scott', 'silverman' or float.) – The bandwidth for kernel density estimation. Check scipy docs about their bw parameter of gaussian_kde.
- grid (GeoDataFrame or None, default is None.) – If a grid is not given, then it is provided according to the area parameter and resolution.
- resolution (float, default is 1.) – Space in kilometers between the arbitrary points of resulting grid.
- area (GeoDataFrame or None, default is None.) – If area is given, grid will be bounded accordingly with the GeoDataFrame passed.
- return_contour_geojson (bool, default is False.) – If True, it returns the result of the kde as a contourplot in the geojson format.
Returns: - GeoDataFrame with a grid of points regularly spaced with the respective
- density values for the input points-of-interest given.
Example
>>> import geohunter as gh >>> poi = gh.osm.Eagle().get(bbox='(-5.91,-35.29,-5.70,-35.15)', amenity=['hospital' , 'police'], natural='*') >>> neighborhood = gh.osm.Eagle().get(bbox='(-5.91,-35.29,-5.70,-35.15)', largest_geom=True, name='Ponta Negra') >>> result = kde_interpolation(poi, bw='scott', area=neighborhood, resolution=0.5) >>> ax = area.plot(edgecolor='black', color='white') >>> result.plot(column='density', ax=ax)
-
geohunter.util.
make_gridpoints
(bbox, resolution=1, return_coords=False)¶ It constructs a grid of points regularly spaced.
Parameters: - bbox (str, GeoDataFrame or dict.) – Corresponds to the boundary box in which the grid will be formed. If a str is provided, it should be in ‘(S,W,N,E)’ format. With a GeoDataFrame, we will use the coordinates of the extremities. Also one can provide a dict with ‘south’, ‘north’, ‘east’, ‘west’.
- resolution (float, default is 1.) – Space between the arbitrary points of resulting grid.
- return_coords (bool) – If it is wanted to return the coordinate sequences.
-
geohunter.util.
make_gridsquares
(city_shape, resolution=1)¶ It constructs a grid of square cells.
Parameters: - city_shape (GeoDataFrame.) – Corresponds to the boundary geometry in which the grid will be formed.
- resolution (float, default is 1.) – Space between the square cells.
-
geohunter.util.
moran_i_ongrid
(data, coords, d_threshold)¶
-
geohunter.util.
parse_bbox
(bbox)¶ Organizes bbox to the standard format used in other places in the package and also in Overpass API.
Parameters: bbox (str, GeoDataFrame or dict.) – Corresponds to the boundary box wanted to be formatted. Returns: Return type: str containing ‘(S,W,N,E)’ coordinates of the bounding box.
-
geohunter.util.
q_ongrid
(data, grid, strata_col)¶