Example #1
0
def write_curated_shapes(w, sf):
    if w.shapeType != shapefile.POLYGON:
        w._shapes.extend(sf.shapes())
    else:
        for shape in sf.iterShapes():
            curated_shape = get_shapely_shape(shape).buffer(0.00000001)
            w._shapes.append(shapely_to_pyshp(curated_shape))
def write_curated_shapes(w, sf):
    if w.shapeType != shapefile.POLYGON:
        w._shapes.extend(sf.shapes())
    else:
        for shape in sf.iterShapes():
            curated_shape = get_shapely_shape(shape).buffer(0.00000001)
            w._shapes.append(shapely_to_pyshp(curated_shape))
Example #3
0
def find_containing_radios(df):
    shp_path = get_division_path("radios_censo_2010")
    sf = shapefile.Reader(shp_path)

    radios_dict = {int(comuna): {} for comuna in df["comuna"].unique()}
    for sr in sf.iterShapeRecords():
        shape = get_shapely_shape(sr.shape)
        radio = sr.record[0]
        comuna = int(radio.split("_")[0])
        radios_dict[comuna][radio] = shape

    return df.apply(find_containing_shape, axis=1,
                    args=(radios_dict, shp_path))
Example #4
0
def find_containing_radios(df):
    shp_path = get_division_path("radios_censo_2010")
    sf = shapefile.Reader(shp_path)

    radios_dict = {int(comuna): {} for comuna in df["comuna"].unique()}
    for sr in sf.iterShapeRecords():
        shape = get_shapely_shape(sr.shape)
        radio = sr.record[0]
        comuna = int(radio.split("_")[0])
        radios_dict[comuna][radio] = shape

    return df.apply(find_containing_shape,
                    axis=1,
                    args=(radios_dict, shp_path))