spaghetti.Network.snapobservations

Network.snapobservations(self, in_data, name, idvariable=None, attribute=None)[source]

Snap a point pattern shapefile to network object. The point pattern is stored in the network.pointpattern['key'] attribute of the network object.

Parameters
in_data{geopandas.GeoDataFrame, str}

The input geographic data. Either (1) a path to a shapefile (str); or (2) a geopandas.GeoDataFrame.

namestr

Name to be assigned to the point dataset.

idvariablestr

Column name to be used as ID variable.

attributebool

Defines whether attributes should be extracted. True for attribute extraction. False for no attribute extraction.

Examples

>>> import spaghetti as spgh
>>> streets_file = examples.get_path('streets.shp')
>>> ntw = spgh.Network(in_data=streets_file)
>>> pt_str = 'crimes'
>>> in_data = examples.get_path('{}.shp'.format(pt_str))
>>> ntw.snapobservations(in_data, pt_str, attribute=True)
>>> ntw.pointpatterns[pt_str].npoints
287