A Coding Implementation on Spatial Graph Neural Networks for City Operate Inference Utilizing city2graph, OSMnx, and PyTorch Geometric
poi_gdf[“cx”] = poi_gdf.geometry.x poi_gdf[“cy”] = poi_gdf.geometry.y coords = poi_gdf[[“cx”, “cy”]].to_numpy() nn = NearestNeighbors(radius=150.0).match(coords) poi_gdf[“local_density”] = [len(idx) – 1 for idx in nn.radius_neighbors(coords, return_distance=False)] if segments_gdf shouldn’t be None and len(segments_gdf): attempt: joined = gpd.sjoin_nearest(poi_gdf[[“geometry”]], segments_gdf[[“geometry”]], distance_col=”dist_street”) poi_gdf[“dist_street”] = joined.groupby(degree=0)[“dist_street”].min().reindex(poi_gdf.index).fillna(0.0) besides Exception: poi_gdf[“dist_street”] = 0.0 else: poi_gdf[“dist_street”] = 0.0 poi_gdf[“category”] = poi_gdf[“category”].astype(“class”) poi_gdf[“label”] = poi_gdf[“category”].cat.codes.astype(int) CLASS_NAMES…
