<jupyter_start><jupyter_text>Pull Points Script ExampleThis Jupyter Notebook demonstrates my pull points script in action. I create this script principally to get around some of the query limits when pulling Geographic data. For example, when using the Google Places API, Google only allows you to pull for first 60 results. If you want data for a whole city, for example, you need to find some way of carving that city up into small sections that you can pull data on. This script does exactly that.In the first step we import our city boundary shapefile (you can also skip this stage and import a polygon directly if you have one).<jupyter_code># Import your shapefile polygon
import geopandas as gpd
gdf = gpd.read_file('test_data/test_data.shp')
gdf.plot()<jupyter_output><empty_output><jupyter_text>If you're working with actual geographic data then you should probably convert the Coordinate Reference System to a local metric one. In the example below, I use OSMNX's bbox from point function. The function is ordinarily used to return a bounding box of a particular size around a point. I don't actually want a bounding box, but the same function includes the ability to project the bouding box into a local local metric projection and returns the local CRS in the process. We just want to extract this CRS.<jupyter_code>import osmnx as ox

# Get the centre point of our polygon which we will feed into OSMNX
centroid = gdf.iloc[0]['geometry'].centroid.y, gdf.iloc[0]['geometry'].centroid.x

# Get the local CRS from OSMXN
crs = ox.utils_geo.bbox_from_point(centroid, project_utm = True, return_crs = True)[-1]
crs
# Covnert our GDF into a local system
gdf = gdf.to_crs(crs)

# Extract the polgyon from the GDF
polygon = gdf.iloc[0]['geometry']
polygon
# Import my pull points script
from pull_points import get_pull_points
help(get_pull_points)
df = get_pull_points(polygon, 10, plot_map = True, plot_legend = True)
df
# Convert our points back into longitude and latitudes
df.crs = crs
df = df.to_crs("epsg:4326")
df['x'] = df.geometry.apply(lambda x: x.x)
df['y'] = df.geometry.apply(lambda x: x.y)
df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06679121905651565, 'fraction_numerical': 0.005604857543204111, 'mean_word_length': 5.0852272727272725, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '666466', 'license': 'MIT', 'n_tokens_mistral': 664, 'n_tokens_neox': 635, 'n_words': 295, 'path': 'Pull Points Example.ipynb', 'repo_name': 'dljthomas1/Get-Pull-Points', 'size': '2141'}