title: How to use python to lookup information at specific latitude/longitude in a ESRI shapefile?
body: <p>I have a ESRI shapefile (from here: <a href="http://pubs.usgs.gov/ds/425/" rel="nofollow">http://pubs.usgs.gov/ds/425/</a>). I looking to use python to lookup information from the shape file (surficial material in this case) at a given latitude/longitude.</p>
  
  <p>What is the best way to go about solving this problem? </p>
  
  <p>Thanks.</p>
  
  <p>Final solution:</p>
  
  <pre><code>#!/usr/bin/python
  
  from osgeo import ogr, osr
  
  dataset = ogr.Open('./USGS_DS_425_SHAPES/Surficial_materials.shp')
  layer = dataset.GetLayerByIndex(0)
  layer.ResetReading()
  
  # Location for New Orleans: 29.98 N, -90.25 E
  point = ogr.CreateGeometryFromWkt("POINT(-90.25 29.98)")
  
  # Transform the point into the specified coordinate system from WGS84
  spatialRef = osr.SpatialReference()
  spatialRef.ImportFromEPSG(4326)
  coordTransform = osr.CoordinateTransformation(
          spatialRef, layer.GetSpatialRef())
  
  point.Transform(coordTransform)
  
  for feature in layer:
      if feature.GetGeometryRef().Contains(point):
          break
  
  for i in range(feature.GetFieldCount()):
      print feature.GetField(i)
  </code></pre>