Ejemplo n.º 1
0
    #~ linear rings; the first linear ring defines the exterior of the polygon, while
    #~ additional rings define "holes" inside the polygon. In this case, we want a
    #~ simple polygon with a square exterior and no holes:
    linearRing = osgeo.ogr.Geometry(osgeo.ogr.wkbLinearRing)
    linearRing.AddPoint(minLon, minLat)
    linearRing.AddPoint(maxLon, minLat)
    linearRing.AddPoint(maxLon, maxLat)
    linearRing.AddPoint(minLon, maxLat)
    linearRing.AddPoint(minLon, minLat)
    polygon = osgeo.ogr.Geometry(osgeo.ogr.wkbPolygon)
    polygon.AddGeometry(linearRing)
    #~ Once we have the polygon, we can use it to create a feature:
    feature = osgeo.ogr.Feature(dstLayer.GetLayerDefn())
    feature.SetGeometry(polygon)
    feature.SetField("CIMCODE", cimCode)
    dstLayer.CreateFeature(feature)
    feature.Destroy()
    #~ Notice how we use the setField() method to store the feature's
    #~ metadata. We also have to call the Destroy() method to close the
    #~ feature once we have finished with it; this ensures that the feature is
    #~ saved into the Shapefile.
    #~ 4.	 Finally, we call the Destroy() method to close the output Shapefile:
    dstFile.Destroy()
    
if __name__=="__main__":
    from pymil import code
    ccode = code(-11, -54)
    minLon, maxLon, minLat, maxLat, cimCode = cimc["100k"]
    #~ cimCode = repr(ccode)
    make_shape(minLon, maxLon, minLat, maxLat, cimCode)
Ejemplo n.º 2
0
# ~ from datetime import date

# ~ from decconv import mag_declination, grid_convergence

from pymil import code

with open("areasMS.csv") as f:
    points = list(csv.reader(f))[1:]

codes_by_area = defaultdict(set)

for lon, lat, point in points:
    print point, lat, lon
    lat = float(lat)
    lon = float(lon)
    cim = code(lat, lon)
    print cim
    codes_by_area[int(point)].add(repr(cim))
    # ~ dec = mag_declination(lat, lon, date(2012, 1, 1))
    # ~ convr = grid_convergence(lat, lon)
    # ~ stuff.append([point, lon, lat, dec[0], dec[1], convr])

stuff = []

for code in codes_by_area.keys():
    foo = [code] + list(codes_by_area[code])
    stuff.append(foo)

print codes_by_area.keys()

print stuff