コード例 #1
0
import numpy as np
from matplotlib import pyplot as plt
from GySon.dataset import load_toyama_second
from matplotlib.colors import LinearSegmentedColormap

cdict = {
    "red": ((0.0, 0.0, 0.0), (0.5, 1.0, 1.0), (1.0, 1.0, 1.0)),
    "green": ((0.0, 0.0, 0.0), (0.5, 1.0, 1.0), (1.0, 0.0, 0.0)),
    "blue": ((0.0, 1.0, 1.0), (0.5, 1.0, 1.0), (1.0, 0.0, 0.0))
}

mycm = LinearSegmentedColormap("mycm", cdict)
sf = load_toyama_second()
x = np.arange(100)
y = np.arange(100, 200)
v = np.random.rand(100)
fig, ax = plt.subplots(figsize=(9, 8))
poly = plt.Polygon(sf["ext"], fc="k")
ax.add_patch(poly)
plt.scatter(x, y, c=v, s=0.8, cmap=mycm)
plt.show()
コード例 #2
0
ファイル: nanto.py プロジェクト: doraneko94/GySon
import shapefile
from GySon.dataset import load_toyama_second, read_csv_data, load_toyama_second_pos
import pickle
from matplotlib import pyplot as plt

sf = load_toyama_second_pos()
sf2 = shapefile.Reader("shp\\A32-13_16.shp", encoding="SHIFT-JIS")
sf3 = load_toyama_second()
fig, ax = plt.subplots()
poly = plt.Polygon(sf3["front"]["南砺市立城端中学校"])
ax.add_patch(poly)
plt.show()
"""
for i, rec in enumerate(sf2.records()):
    if rec[1] == "南砺市":
        print(rec[2])
        fig, ax = plt.subplots()
        poly = plt.Polygon(sf2.shape(i).points)
        ax.add_patch(poly)
        for j, r in enumerate(sf.keys()):
            if rec[2] in r:
                ax.plot(sf[r][0], sf[r][1], "o", c="r")
                break
        plt.show()
"""
print(sf3["front"].keys())
コード例 #3
0
ファイル: rand.py プロジェクト: doraneko94/GySon
cdict = {"red":     ((0.0, 0.0, 0.0),
                     (0.5, 1.0, 1.0),
                     (1.0, 1.0, 1.0)),
         "green":   ((0.0, 0.0, 0.0),
                     (0.5, 1.0, 1.0),
                     (1.0, 0.0, 0.0)),
         "blue":    ((0.0, 1.0, 1.0),
                     (0.5, 1.0, 1.0),
                     (1.0, 0.0, 0.0))
        }

mycm = LinearSegmentedColormap("mycm", cdict)

np.random.seed(42)
sf = load_toyama_second_pos()
sf2 = load_toyama_second()
xyv_dict = {}
for key in sf.keys():
    xyv_dict[key] = [sf[key], (sf[key][0]-36) + (sf[key][1]-136) + np.random.random()*2 - 1.0]
    for k in sf2["data"].keys():
        if key in k:
            sf2["data"][k] = xyv_dict[key][1]
heatmap(sf2, title="heat", save_name="heat.png")
xy = np.array([xyv_dict[key][0] for key in sf.keys()])
v = np.array([xyv_dict[key][1] for key in sf.keys()])

param, lag_h, fitting_range, selected_model = semivariogram(xy, v, lag_h=0.02, fitting_range=0.3, plot=True, plot_raw=True)
print(lag_h, fitting_range, selected_model)

x_back = [x for i in sf2["back"].keys() for x,_ in sf2["back"][i]]
y_back = [y for i in sf2["back"].keys() for _,y in sf2["back"][i]]