title: Python: how to check if shape areas contain points?
body: <p>I have a <code>shapefile</code> of Singapore that I visualize in this way:</p>
  
  <pre><code>import shapefile
  import matplotlib.pyplot as plt
  import matplotlib.patches as patches
  from matplotlib.patches import Polygon
  from matplotlib.collections import PatchCollection
  ### Plot shapefile
  sf = shapefile.Reader("myShape.shp")
  recs    = sf.records()
  shapes  = sf.shapes()
  Nshp    = len(shapes)
  cns     = []
  for nshp in xrange(Nshp):
      cns.append(recs[nshp][1])
  cns = array(cns)
  cm    = get_cmap('Dark2')
  cccol = cm(1.*arange(Nshp)/Nshp)
  #   -- plot --
  fig,ax = plt.subplots(figsize=(20,10))
  
  for nshp in xrange(Nshp):
      ptchs   = []
      pts     = array(shapes[nshp].points)
      prt     = shapes[nshp].parts
      par     = list(prt) + [pts.shape[0]]
      for pij in xrange(len(prt)):
          ptchs.append(Polygon(pts[par[pij]:par[pij+1]]))
          ax.add_collection(PatchCollection(ptchs,facecolor=cccol[nshp,:],edgecolor='k', linewidths=.1))     
  ax.set_xlim(103.6,104.1)
  ax.set_ylim(1.15,1.48)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/FHsmu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FHsmu.png" alt="enter image description here"></a></p>
  
  <p>Now I have a list of points with coordinates in a <code>dataframe</code> and I want to check in which region of the shapefile the points are.</p>
  
  <pre><code>mypoints
      lon         lat
  0   103.619740  1.280485
  1   103.622632  1.268944
  2   103.622632  1.274714
  3   103.622632  1.277600
  4   103.622632  1.280485
  </code></pre>
  
  <p>In particular from the <code>shapefile</code> I can extract information of the specific area such as the <code>name</code>. In fact, in <code>recs</code> I have this information. For instance:</p>
  
  <pre><code>recs[0]:
  
  [42,
   1,
   'STRAITS VIEW',
   'SVSZ01',
   'Y',
   'STRAITS VIEW',
   'SV',
   'CENTRAL REGION',
   'CR',
   '21451799CA1AB6EF',
   datetime.date(2016, 5, 11),
   30832.9017,
   28194.0843,
   5277.76082729,
   1127297.23737]
  </code></pre>
  
  <p>In this case <code>STRAITS VIEW</code> is the name of the area. At the the end I would like to have a <code>dataframe</code> like:</p>
  
  <pre><code>mypoints
      lon         lat       name
  0   103.619740  1.280485  STRAITS VIEW
  1   103.622632  1.268944  STRAITS VIEW
  2   103.622632  1.274714  DOWNTOWN
  3   103.622632  1.277600  BEDOK
  4   103.622632  1.280485  CHANGI
  </code></pre>