简体   繁体   English

Python 可以从卫星图像中导出纬度/经度吗?

[英]Can Python export latitude/longitude from Satellite images?

I have a satellite image and it has latitude/longitude for each pixel.我有一张卫星图像,每个像素都有纬度/经度。 Can I export the coordinate value of each pixel to.CSV file or.txt file by using Python?我可以使用Python将每个像素的坐标值导出到.CSV文件或.txt文件吗? If it can,how to do that?如果可以,该怎么做?

Yes you can export latitude/longitude from satellite images.是的,您可以从卫星图像中导出纬度/经度。 For.tif images Below is the source code. For.tif images 下面是源代码。

import numpy as np import pandas as pd import rasterio as rio导入 numpy 作为 np 导入 pandas 作为 pd 导入 rasterio 作为 rio

tifImage = "imagename.tif" tifImage = "图像名.tif"

def extractLatLon(imageName, NumOfBands): 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') 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) lat, lon = extractLatLon("ImageName.tif", NumOfBands=3) DataFrame(lat, lon)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 plotly python 从 pandas 数据帧中标记点(使用纬度和经度)与卫星视图 - how to mark points(using latitude and longitude) from pandas data frame using plotly python with satellite view 使用纬度经度坐标从卫星图像中获取最近的像素值 - Get nearest pixel value from satellite image using latitude longitude coordinates 在 Python 3.6 中从 CSV 绘制纬度经度 - Plot latitude longitude from CSV in Python 3.6 Python:从具有经度和纬度的数据帧进行 A* 路由 - Python: A* routing from dataframe with longitude and latitude Python Selenium - 从地图上抓取纬度和经度 - Python Selenium - Webscrape Latitude and Longitude from the Maps 在Python中将SRS坐标转换为纬度和经度 - Convert from SRS coordinates to Latitude and Longitude in Python Python:从纬度和经度值获取高程 - Python: Obtaining elevation from latitude and longitude values python中的经纬度聚类 - latitude and longitude clustering in python 使用 python 进行经纬度聚类 - Clustering with longitude and latitude with python 无法在 NetCDF 卫星文件 (Xarray) 中沿纬度和经度切片 - Unable to slice along latitude and longitude in NetCDF satellite file (Xarray)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM