2 Star 4 Fork 3

汉塞大叔/Geospatial_Analysis_By_Python

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
1.4 数据格式.py 1.99 KB
Copy Edit Raw Blame History
汉塞大叔 authored 2021-01-20 19:53 +08:00 . 上传 py
"""
1. .jpg .png .bmp
图片栅格文件,将其转化为array
下面例子为3*3像素的图片,每一个[255,255,255]代表一个白色像素
[[[255,255,255],[255,255,255],[255,255,255]],
[[255,255,255],[255,255,255],[255,255,255]],
[[255,255,255],[255,255,255],[255,255,255]]]
2. .asc
grid网格文件
[[42.28 42.28 42.27 ... 50.56 50.62 50.68]
[45.27 44.99 42.4 ... 50.06 50.08 50.07]
[45.14 43.24 42.42 ... 50.1 50.12 50.11]
...
[42.41 42.42 42.41 ... 50.58 50.61 50.66]
[42.37 42.36 42.35 ... 50.6 50.61 50.67]
[42.32 42.34 42.32 ... 50.57 50.62 50.67]]
3. .tif
包含红绿蓝三个波长的数据
[ # r
[[ 77 89 96 ... 56 58 59]
...
[ 8 9 9 ... 10 10 10]]
# g
[[ 22 24 25 ... 14 14 13]
...
[ 4 3 3 ... 6 5 5]]
# b
[[ 57 60 58 ... 52 53 53]
...
[ 60 61 61 ... 67 67 67]]
]
tif 包含地理空间
# 同时载入gdal库的图片从而获取 geotransform(世界文件)
srcImage = gdal.Open(tifPath)
geoTrans = srcImage.GetGeoTransform()
# 使用GDAL库的geomatrix对象计算地理坐标的像素位置
def world2Pixel(geoMatrix, x, y):
ulX = geoMatrix[0]
ulY = geoMatrix[3]
xDist = geoMatrix[1]
yDist = geoMatrix[5]
rtnX = geoMatrix[2]
rtnY = geoMatrix[4]
pixel = int((x - float(ulX)) / float(xDist))
line = int((float(ulY) - y) / abs(float(yDist)))
return pixel, line
# 详见 7.4
4. shp 文件
shp文件基本有 .shp .shx .dbf组成 .prj为地理坐标系统
其中.shp .shx .dbf 为一个整体,构成shp文件的基础
包含 图形、字段、记录
无论图形是点、线、面,shape都是以点的形式储存坐标数据
"""
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/fengfeng233/geospatial_-analysis_-by_-python.git
git@gitee.com:fengfeng233/geospatial_-analysis_-by_-python.git
fengfeng233
geospatial_-analysis_-by_-python
Geospatial_Analysis_By_Python
master

Search