Exemplo n.º 1
0
def test_gmap():

    g = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13,
                        size_x=640, size_y=640)

    m = Map(g.grid, countries=False, nx=640)
    m.set_lonlat_countours(interval=0.025)
    m.set_shapefile(get_demo_file('Hintereisferner.shp'),
                    linewidths=2, edgecolor='darkred')
    m.set_rgb(g.get_vardata())
    m.visualize(addcbar=False)

    dem = salem.GeoTiff(get_demo_file('hef_srtm.tif'))
    dem.set_subset(margin=-100)

    dem = salem.grids.local_mercator_grid(center_ll=(10.76, 46.798444),
                                               extent=(10000, 7000))

    i, j = dem.ij_coordinates
    g = GoogleVisibleMap(x=i, y=j, src=dem, size_x=500, size_y=400)
    img = g.get_vardata()

    m = Map(dem, countries=False)

    assert_raises(ValueError, m.set_data, img)

    m.set_lonlat_countours(interval=0.025)
    m.set_shapefile(get_demo_file('Hintereisferner.shp'),
                    linewidths=2, edgecolor='darkred')
    m.set_rgb(img, g.grid)
    m.visualize(addcbar=False)
Exemplo n.º 2
0
    def test_center(self):

        gm = GoogleCenterMap(center_ll=(10.762660, 46.794221),
                             zoom=13,
                             size_x=500,
                             size_y=500,
                             use_cache=False)
        gm.set_roi(shape=get_demo_file('Hintereisferner.shp'))
        gm.set_subset(toroi=True, margin=10)
        img = gm.get_vardata()
        img[np.nonzero(gm.roi == 0)] /= 2.

        # from scipy.misc import toimage
        # toimage(img).save(get_demo_file('hef_google_roi.png'))
        ref = mpl.image.imread(get_demo_file('hef_google_roi.png'))
        rmsd = np.sqrt(np.mean((ref - img)**2))
        self.assertTrue(rmsd < 0.1)
        # assert_allclose(ref, img, atol=2e-2)

        gm = GoogleCenterMap(center_ll=(10.762660, 46.794221),
                             zoom=13,
                             size_x=500,
                             size_y=500)
        gm.set_roi(shape=get_demo_file('Hintereisferner.shp'))
        gm.set_subset(toroi=True, margin=10)
        img = gm.get_vardata()
        img[np.nonzero(gm.roi == 0)] /= 2.
        rmsd = np.sqrt(np.mean((ref - img)**2))
        self.assertTrue(rmsd < 0.1)
Exemplo n.º 3
0
    def test_center(self):
        import matplotlib as mpl
        gm = GoogleCenterMap(center_ll=(10.762660, 46.794221),
                             zoom=13,
                             size_x=500,
                             size_y=500,
                             use_cache=False)
        gm.set_roi(shape=get_demo_file('Hintereisferner.shp'))
        gm.set_subset(toroi=True, margin=10)
        img = gm.get_vardata()[..., :3]
        img[np.nonzero(gm.roi == 0)] /= 2.

        # from PIL import Image
        # Image.fromarray((img * 255).astype(np.uint8)).save(
        #     get_demo_file('hef_google_roi.png'))
        ref = mpl.image.imread(get_demo_file('hef_google_roi.png'))
        rmsd = np.sqrt(np.mean((ref - img)**2))
        self.assertTrue(rmsd < 0.2)
        # assert_allclose(ref, img, atol=2e-2)

        gm = GoogleCenterMap(center_ll=(10.762660, 46.794221),
                             zoom=13,
                             size_x=500,
                             size_y=500)
        gm.set_roi(shape=get_demo_file('Hintereisferner.shp'))
        gm.set_subset(toroi=True, margin=10)
        img = gm.get_vardata()[..., :3]
        img[np.nonzero(gm.roi == 0)] /= 2.
        rmsd = np.sqrt(np.mean((ref - img)**2))
        self.assertTrue(rmsd < 0.2)

        gm = GoogleCenterMap(center_ll=(10.762660, 46.794221),
                             zoom=13,
                             size_x=500,
                             size_y=500)
        gm2 = GoogleCenterMap(center_ll=(10.762660, 46.794221),
                              zoom=13,
                              size_x=500,
                              size_y=500,
                              scale=2)
        assert (gm.grid.nx * 2) == gm2.grid.nx
        assert gm.grid.extent == gm2.grid.extent
Exemplo n.º 4
0
    def test_center(self):

        gm = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13, size_x=500, size_y=500, use_cache=False)
        gm.set_roi(shape=get_demo_file("Hintereisferner.shp"))
        gm.set_subset(toroi=True, margin=10)
        img = gm.get_vardata()
        img[np.nonzero(gm.roi == 0)] /= 2.0

        # from scipy.misc import toimage
        # toimage(img).save(get_demo_file('hef_google_roi.png'))
        ref = mpl.image.imread(get_demo_file("hef_google_roi.png"))
        rmsd = np.sqrt(np.mean((ref - img) ** 2))
        self.assertTrue(rmsd < 0.1)
        # assert_allclose(ref, img, atol=2e-2)

        gm = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13, size_x=500, size_y=500)
        gm.set_roi(shape=get_demo_file("Hintereisferner.shp"))
        gm.set_subset(toroi=True, margin=10)
        img = gm.get_vardata()
        img[np.nonzero(gm.roi == 0)] /= 2.0
        rmsd = np.sqrt(np.mean((ref - img) ** 2))
        self.assertTrue(rmsd < 0.1)