Untitled
unknown
python
5 years ago
968 B
12
Indexable
os.chdir("D:\Studia_magisterka\semestr_2\Eksploracja_danych_uczenie_maszynowe\zaliczenie_2\img")
#stworzenie rastra ze wszystkimi pasmami
band2 = rio.open("B02.jp2")
band3 = rio.open("B03.jp2")
band4 = rio.open("B04.jp2")
band8 = rio.open("B08.jp2")
band2 = np.array(band2)
band2_geo = band2.profile
band2_geo.update({"count": 4})
band2_geo.update({"driver": 'GTiff'})
with rio.open('data.tiff', 'w+', **band2_geo) as dest:
dest.write(band2.read(1),1)
dest.write(band3.read(1),2)
dest.write(band4.read(1),3)
dest.write(band4.read(1),4)
#Tworzenie próby
cl = ['b02','b03','b04','b08']
proby = gpd.read_file("proby.gpkg")
with rio.open("data.tiff", "r") as dst:
samples = [s for s in dst.sample(zip(proby.geometry.x, proby.geometry.y))]
samples = np.array(samples)
samples = pd.DataFrame(samples,
columns = cl,
index = proby.index)
proby_s = proby.join(samples)Editor is loading...