2016-12-01 163 views
0

首先,我安装了pygeobuf如何运行安装的python模块

它被安装后,我不知道如何使用它。该文件说,它不适用于Windows。

在windows中,我尝试了各种方法,但仍然失败。

在Windows命令行,

python (get into interpreter) 

import geobuf 
geobuf.encode("city_streets.geojson", "c.pbf") 

Traceback (most recent call last): 
File "", line 1, in 
File "C:\PYTHON27\lib\site-packages\geobuf-1.1.0-py2.7.egg\geobuf_init_.py" 
, line 8, in encode 
return Encoder().encode(*args) 
File "C:\PYTHON27\lib\site-packages\geobuf-1.1.0-py2.7.egg\geobuf\encode.py", 
line 30, in encode 
self.e = pow(10, precision) # multiplier for converting coordinates into int 
egers 
TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'str' 

你能告诉我,我错了吗?

+0

因此,文件说,它不工作在Windows上,你尝试过了,它不能在Windows工作...?是什么让你觉得它应该工作? –

回答

0

encode()需要2个参数,一个是加载的json文件,第二个是可选的精度值。

正确的用法如下:

import json 
import geobuf 


# replace with path to city_streets file 
with open("city_streets.geojson") as file: 
    loadedJson = json.load(file) 

encoded = geobuf.encode(loadedJson) 

print(encoded)