查找GeoTiff图像中每个像素的纬度/经度坐标 [英] Find Latitude/Longitude Coordinates of Every Pixel in a GeoTiff Image
问题描述
我目前有一个GeoTiff文件中的171 x 171图像(尽管在其他情况下,我的图像可能更大).我的目标是获取图像中的每个像素并转换为纬度/经度对.
I currently have a 171 x 171 image from a GeoTiff file (although in other cases, I might have much bigger images). My goal is to take each pixel in the image and convert to latitude/longitude pair.
我已经能够基于以下StackOverflow帖子将图像的角点转换为纬度/经度对:
I am already able to convert the corners of the image to latitude/longitude pair based on this StackOverflow post: Obtain Latitude and Longitude from a GeoTIFF File. This post was helpful since my original coordinates were in UTM Zone 15.
但是,我现在想将图像的所有像素转换为纬度,经度对,并将结果存储在相同尺寸的numpy数组中.因此,输出将是一个171 x 171 x 2的numpy数组,该numpy数组的每个元素都是(经度,纬度)对的元组.
However, I now want to convert all of the pixels of the image to latitude, longitude pair and store the results in a numpy array of the same dimension. So the output would be a numpy array that is 171 x 171 x 2 with each element of the numpy array being a tuple of the (longitude, latitude) pair.
The most relevant post I've seen on this is https://scriptndebug.wordpress.com/2014/11/24/latitudelongitude-of-each-pixel-using-python-and-gdal/. However, that post suggests to essentially create a for loop over each pixel and convert to latitude, longitude. Is there a way that is more efficient?
仅在实际使用情况下提供更多背景信息,我的最终目标是获得一堆卫星图像(例如,在这种情况下,每个图像为171 x 171).我正在尝试创建建筑物分割模型.现在,我试图通过在每个图像上创建一个遮罩来产生标记的数据点,该遮罩将像素标记为1(如果它对应于建筑物),否则标记为0.首先,我使用的是Microsoft US Building Footprint数据:
Just to give more context on my actual use case, my end goal is I have a bunch of satellite imagery (for example in this case, each image is 171 x 171). I am trying to create a building segmentation model. Right now, I am trying to produce labeled data points by creating a mask on each image that labels a pixel a 1 if it corresponds to a building, else 0. To start, I'm using the Microsoft US Building Footprint data: https://github.com/microsoft/USBuildingFootprints where they've released GeoJSON files of polygons (defined by latitude, longitude) of buildings they've detected. The way I'm thinking about doing this is: