Ejemplo n.º 1
0
    def test_reproject_point(self):
        shp_path = pf.get_shp("RADIO")
        lat, lon = -34.567277, -58.440509
        point = reproject_point(lat, lon, shp_path)
        reproj_coords = list(point.coords)[0]
        exp_reproj_coords = (1476458.5151069912, -2797102.116439601)

        self.assertAlmostEqual(reproj_coords[0], exp_reproj_coords[0])
        self.assertAlmostEqual(reproj_coords[1], exp_reproj_coords[1])
Ejemplo n.º 2
0
    def test_reproject_point(self):
        shp_path = pf.get_shp("RADIO")
        lat, lon = -34.567277, -58.440509
        point = reproject_point(lat, lon, shp_path)
        reproj_coords = list(point.coords)[0]
        exp_reproj_coords = (1476458.5151069912, -2797102.116439601)

        self.assertAlmostEqual(reproj_coords[0], exp_reproj_coords[0])
        self.assertAlmostEqual(reproj_coords[1], exp_reproj_coords[1])
Ejemplo n.º 3
0
def find_containing_shape(row, radios_dict, shp_path):
    lat = row["y"]
    lon = row["x"]
    comuna = int(row["comuna"])
    point = reproject_point(lon, lat, shp_path)

    for id_shape, shape in radios_dict[comuna].iteritems():
        if shape.contains(point):
            return id_shape

    return None
Ejemplo n.º 4
0
def find_containing_shape(row, radios_dict, shp_path):
    lat = row["y"]
    lon = row["x"]
    comuna = int(row["comuna"])
    point = reproject_point(lon, lat, shp_path)

    for id_shape, shape in radios_dict[comuna].iteritems():
        if shape.contains(point):
            return id_shape

    return None
Ejemplo n.º 5
0
def find_id_intersecting_shape(lat, lon, shapes, shp_path):
    """Return id of shape containing the lat-lon point."""
    point = reproject_point(lon, lat, shp_path)

    # for id_shp, shp in find_intersections(point.buffer(0.1), shapes,
    # shp_idx):
    for id_shp, shp in shapes:
        if shp.contains(point):
            # print(lat, lon, "is", id_shp)
            return id_shp

    return None
Ejemplo n.º 6
0
def find_id_intersecting_shape(lat, lon, shapes, shp_path):
    """Return id of shape containing the lat-lon point."""
    point = reproject_point(lon, lat, shp_path)

    # for id_shp, shp in find_intersections(point.buffer(0.1), shapes,
    # shp_idx):
    for id_shp, shp in shapes:
        if shp.contains(point):
            # print(lat, lon, "is", id_shp)
            return id_shp

    return None