![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
齐鲁明月
get busy dying or get busy living
展开
-
VSCode Pytest测试
# 参考- Python testing in Visual Studio Code- VSCode Python原创 2021-05-10 15:44:50 · 5379 阅读 · 1 评论 -
GDAL/OGR空间过滤之SetSpatialFilter()
SetSpatialFilter函数SetSpatialFitler函数在osgeo.ogr模块下的Layer类中。SetSpatialFilter(Geometry filter)输入中的Geometry作为过滤的参数。示例Pythonfrom osgeo imiport ogrimport osshp_file = 'sates.shp'drv = ogr.GetDriverByName('ESRI Shapefile')ds = drv.Open(shp_file)lyr = d原创 2021-02-03 16:16:40 · 1733 阅读 · 0 评论 -
ogr2ogr转坐标
转坐标的方式有多种。可以用GDAL的Python绑定库。当然最方便的还是用ogr2ogr命令行的方式,效率又高。import subprocesscmd = 'ogr2ogr -f "ESRI Shapefile" out.shp in.shp -s_srs EPSG:4326 -t_srs EPSG:3857'subprocess.call(cmd) 如果要查看转换的进度,可以在加上参数-progress,即如下:import subprocesscmd = 'ogr2ogr -progre原创 2021-01-30 11:50:15 · 669 阅读 · 0 评论 -
GDAL/OGR空间过滤之SetSpatialFilterRect()
g = ogr.Open('world.shp')lyr = g.GetLyaer(0)lyr.SetSpatialFilterRect(-14, 37, 38, 72)for feat in lyr: print(feat.GetFieldAsString('NAME') + '------'+feat.GetFieldAsString('CAPITAL'))ALGERIA ---- ALGIERSBELGIUM ---- BRUSSELSLUXEMBOURG ---- LUXEMBOU原创 2021-01-27 15:26:30 · 1061 阅读 · 0 评论 -
Fiona写shapefile的效率
Fiona关于性能的描述之一Fiona翻译Fiona’s performance is relatively more slow if you only need access to a single record field – and of course if you just want to reproject or filter data files, nothing beats the ogr2ogr program - but Fiona’s performance is原创 2021-01-22 18:19:30 · 163 阅读 · 0 评论 -
GDAL Python读取.pbf文件
GDAL原创 2020-08-09 08:21:52 · 1976 阅读 · 0 评论 -
sqlite3, json1扩展及pysqlite3
在python3中使用sqlite3进行JSON数据的操作,但是发现python中自带的sqlite3,没有扩展。1. 查看sqlite3的编译选项a = conn.execute("pragma compile_options;")for i in a: print(i)输出结果如下:('COMPILER=msvc-1924',)('ENABLE_FTS4',)('ENABLE_FTS5',)('THREADSAFE=1',)可以看到,其中并不包含JSON1的支持.原创 2020-07-11 12:00:27 · 764 阅读 · 0 评论