Это мой код:
Код: Выделить всё
import rasterio.transform
import snowgis_hn_utils as hn
import glob
import os
import matplotlib.pyplot as plt
import pandas
import geopandas
import numpy
from shapely import Point
from scipy.interpolate import griddata
from skimage import measure
#data = pandas.read_csv(file, sep=",")
#data_geo = geopandas.GeoDataFrame(data, geometry=geopandas.points_from_xy(data.longitude, data.latitude))
points = [[7.481479858, 46.33465909],
[7.481419827, 46.33467655],
[7.481358293, 46.33469339],
[7.481294507, 46.33471043],
[7.481231878, 46.33472677],
[7.481173172, 46.33474505],
[7.481648, 46.33465],
[7.4816235, 46.33466],
[7.4815875, 46.33467],
[7.481547, 46.33469],
[7.4815065, 46.33470],
[7.481467, 46.33471],
[7.4814275, 46.334715],
[7.48139, 46.33473],
[7.4813545, 46.33474],
[7.481321, 46.33475],
[7.481288, 46.33476],
[7.4812555, 46.33477],
[7.481221, 46.33478],
[7.481184, 46.33479],
[7.481649023, 46.33467052],
[7.481596643, 46.33468609],
[7.481545527, 46.33470014],
[7.481492227, 46.33471225]]
values = [1.3, 1.0, 0.95, 0.90, 0.80, 0.70, 1.40, 1.35, 1.20, 1.30, 1.40, 1.25, 1.35, 1.45, 1.45, 1.35, 1.30, 1.20, 1.25, 1.30, 1.05, 0.80, 0.90, 0.95]
grid_x, grid_y = numpy.mgrid[
7.481173172:7.481649023:100j,
46.33465000:46.33479000:100j
]
grid_z = griddata(points, values, (grid_x, grid_y), method='linear')
plt.figure()
plt.imshow(grid_z.T, extent=(7.481173172, 7.481649023, 46.33465000, 46.33479000), origin='lower', cmap="RdYlGn")
contours = measure.find_contours(grid_z.T, 1)
if len(contours) > 0:
plt.figure()
for contour in contours:
plt.plot(contour[:, 1], contour[:, 0], linewidth=2, color="k")
else:
print("Not values")
Подробнее здесь: https://stackoverflow.com/questions/788 ... hod-return