Given a a point (lat, lng)
and a projection crs
create
a bounding box square given by miles
to select rows
in a geopandas GeoDataFrame
where the geometry is made up
of other points.
Seems like pyproject
should do it but I can only find examples
of converting from one projection to another. I want raw coordinates
projected to the current projection. In this case miles would be nice.
import pandas as pd
import geopandas as gpd
import shapely as shp
#import pyproject ?
def rowsWithinDistanceByPoint(gdf, lat, lng, miles=10, crs='epsg:4269')
# we do not know to use miles yet so ...
tenmilesish = 1/6.0 #lame
circle = shp.geometry.Point(lng, lat).buffer(tenmileish)
# we really want converted coords
#(xmin, ymin, xmax, ymax) = magicFunction(miles, crs)
# but this sort of gets us there if were not next to the poles
xmin, ymin, xmax, ymax = circle.bounds
return gdf.cx[xmin:xmax, ymin:ymax]
So this should return the rows that are within 10 miles of the point.