Exemple #1
0
def test_warp_tiles():
    w, s, e, n = (
        -106.6495132446289,
        25.845197677612305,
        -93.50721740722656,
        36.49387741088867,
    )
    img, ext = ctx.bounds2img(w, s, e, n, zoom=4, ll=True)
    wimg, wext = ctx.warp_tiles(img, ext)
    assert wext == (
        -112.54394531249996,
        -90.07903186397023,
        21.966726124122374,
        41.013065787006276,
    )
    assert wimg[100, 100, :].tolist() == [228, 221, 184]
    assert wimg[100, 200, :].tolist() == [213, 219, 177]
    assert wimg[200, 100, :].tolist() == [133, 130, 109]
Exemple #2
0
print("Joining DataFrames together")
signal = pd.concat(signals)
signal["date"] = pd.to_datetime(signal.utc_timestamp,
                                unit="ms").map(pd.Timestamp.date)
gsignal = gpd.GeoDataFrame(signal,
                           geometry=gpd.points_from_xy(signal.lon, signal.lat))
gsignal.crs = "EPSG:4326"

west, south, east, north = (13.05, 52.35, 13.79, 52.65)

img, ext = cx.bounds2img(west,
                         south,
                         east,
                         north,
                         ll=True,
                         source=cx.providers.Stamen.TonerLite,
                         zoom=12)

img, ext = cx.warp_tiles(img, ext, "EPSG:4326")

f, ax = plt.subplots(1, figsize=(9, 9))
plt.imshow(img, extent=ext)
gplt.kdeplot(gsignal[gsignal.device_id == 8704],
             ax=ax,
             cmap="Reds",
             shade=True,
             shade_lowest=False)

plt.savefig("users.png", bbox_inches="tight")