Пример #1
0
def log_data_frame(gdf: GeoDataFrame) -> None:
    logger.debug(gdf.head())

    buffer = StringIO()
    gdf.info(buf=buffer)
    logger.debug(buffer.getvalue())
Пример #2
0
    return [xy for xy in coord_xy if (~(np.isnan(xy[0]) or np.isnan(xy[1])))]


# #convert to geodataframe

# In[5]:

geometry = [
    LineString(build_coord_tuples(x)) for x in df_traffic_links.LINK_POINTS
]
crs = {'init': 'epsg:4326'}
geodf_traffic_links = GeoDataFrame(df_traffic_links.drop('LINK_POINTS',
                                                         axis=1),
                                   crs=crs,
                                   geometry=geometry)
geodf_traffic_links.info()
geodf_traffic_links.head()

# In[6]:

geodf_traffic_links.plot(color='r')
plt.show()

# # JOIN TRANSIT STATIONS WITH TRAFFIC LINKS

# In[7]:

#LOAD STATION GEO DF (ALREADY PROCESSED IN STATIONS NOTEBOOK)
#file = root + 'transit/Stations_geomerged.geojson'
#geodf_stations = GeoDataFrame.from_file(file)[['STATION','geometry']]
#geodf_stations.head()
df_stations.head()

# #convert to geodataframe

# In[6]:

geometry = [
    Point(xy) for xy in zip(df_stations.LATITUDE, df_stations.LONGITUDE)
]
df_stations = df_stations.drop(['LATITUDE', 'LONGITUDE'], axis=1)
crs = {'init': 'epsg:4326'}
geodf_stations = GeoDataFrame(df_stations, crs=crs, geometry=geometry)

# In[7]:

geodf_stations.info()
geodf_stations.head()

# In[8]:

#add a new geometry to geodf_stations of a circle of X miles around each station
#new design uses polygons that will be loaded from a shape file so drawing buffer circles around the stations will not be required
#X = 0.01
#geodf_stations['CIRCLE'] = geodf_stations.geometry.buffer(X)
#geodf_stations.geometry.name
#geodf_stations = geodf_stations.rename(columns={'geometry':'POINT'}).set_geometry('CIRCLE')
#geodf_stations.geometry.name
#geodf_stations.info()
#geodf_stations.head()

# # LOAD STATIONS FROM TRANSIT DATA
Пример #4
0
                          ])

df_stations.columns = [
    'STATION_ID', 'STOP_ID', 'STOP_NAME', 'BOROUGH', 'LATITUDE', 'LONGITUDE'
]

# convert to geodataframe

geometry = [
    Point(xy) for xy in zip(df_stations.LATITUDE, df_stations.LONGITUDE)
]
df_stations = df_stations.drop(['LATITUDE', 'LONGITUDE'], axis=1)
crs = {'init': 'epsg:4326'}
geodf_stations = GeoDataFrame(df_stations, crs=crs, geometry=geometry)

geodf_stations.info()
geodf_stations.head()

# In[8]:

#add a new geometry to geodf_stations of a circle of X miles around each station
#new design uses polygons that will be loaded from a shape file so drawing buffer circles around the stations will not be required
#X = 0.01
#geodf_stations['CIRCLE'] = geodf_stations.geometry.buffer(X)
#geodf_stations.geometry.name
#geodf_stations = geodf_stations.rename(columns={'geometry':'POINT'}).set_geometry('CIRCLE')
#geodf_stations.geometry.name
#geodf_stations.info()
#geodf_stations.head()

# # LOAD STATIONS FROM TRANSIT DATA