spaghetti 1.3.1
  • Installation
  • API
  • References
  • Site

      Contents:

      • Installation
        • Installing with conda via spaghetti-feedstock (highly recommended)
        • Installing with Python Package Index
        • Development Version
      • API
        • spaghetti.Network
        • spaghetti.PointPattern
        • spaghetti.SimulatedPointPattern
        • spaghetti
      • References
  • Page
      • spaghetti.Network.count_per_link

spaghetti.Network.count_per_link¶

Network.count_per_link(self, obs_on, graph=True)[source]¶

Compute the counts per arc or edge (link).

Parameters
obs_on_networkdict

Dictionary of observations on the network. Either {(link):{pt_id:(coords)}} or {link:[(coord),(coord),(coord)]}

Returns
countsdict

{(link):count}

Examples

Note that this passes the obs_to_arc or obs_to_edge attribute of a point pattern snapped to the network.

>>> import spaghetti as spgh
>>> ntw = spgh.Network(examples.get_path('streets.shp'))
>>> ntw.snapobservations(examples.get_path('crimes.shp'),
...                                        'crimes',
...                                         attribute=True)
>>> counts = ntw.count_per_link(ntw.pointpatterns['crimes']
...                             .obs_to_arc, graph=False)
>>> counts[(140, 142)]
10
>>> s = sum([v for v in list(counts.values())])
>>> s
287

Back to top

Source

© Copyright 2018, pysal developers.
Created using Sphinx 2.2.0.