![](/img/trans.png)
[英]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.