[英]how to mark points(using latitude and longitude) from pandas data frame using plotly python with satellite view
[英]Can Python export latitude/longitude from Satellite images?
我有一張衛星圖像,每個像素都有緯度/經度。 我可以使用Python將每個像素的坐標值導出到.CSV文件或.txt文件嗎? 如果可以,該怎么做?
是的,您可以從衛星圖像中導出緯度/經度。 For.tif images 下面是源代碼。
導入 numpy 作為 np 導入 pandas 作為 pd 導入 rasterio 作為 rio
tifImage = "圖像名.tif"
def extractLatLon(imageName, NumOfBands):
with rio.open(imageName) as src:
image = src.read(NumOfBands)
height, width = image.shape[0], image.shape[1]
rows, cols = np.meshgrid(np.arange(width), np.arange(height))
xs, ys = rio.transform.xy(src.transform, rows, cols)
lat, lon = np.array(xs), np.array(ys)
return lat, lon
# Flatten lat, lon if you want to [according to your needs]
def DataFrame(lat, lon): return pd.DataFrame({'lat': lat, 'lon': lon}).to_csv('File_name_to_be_saved.csv')
lat, lon = extractLatLon("ImageName.tif", NumOfBands=3) DataFrame(lat, lon)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.