用于对geojson数据执行查询和转换的库(重点是支持抽象图形表示)。

geoql的Python项目详细描述


用于对geojson数据执行查询和转换的库(重点是支持抽象图形表示)。

软件包安装和使用

PYPI上提供该软件包:

python -m pip install geoql

库可以用通常的方式导入:

import geoql
from geoql import geoql

示例

用法示例如下:

import geojson
from geoql import geoql
import geoleaflet
import requests

url = 'https://raw.githubusercontent.com/Data-Mechanics/geoql/master/examples/'

# Boston ZIP Codes regions.
z = geoql.loads(requests.get(url + 'example_zips.geojson').text, encoding="latin-1")

# Extract of street data.
g = geoql.loads(requests.get(url + 'example_extract.geojson').text, encoding="latin-1")

g = g.properties_null_remove()\
     .tags_parse_str_to_dict()\
     .keep_by_property({"highway": {"$in": ["residential", "secondary", "tertiary"]}})
g = g.keep_within_radius((42.3551, -71.0656), 0.75, 'miles') # 0.75 miles from Boston Common.
g = g.keep_that_intersect(z) # Only those entries found in a Boston ZIP Code regions.
g = g.node_edge_graph() # Converted into a graph with nodes and edges.
g.dump(open('example_extract.geojson', 'w'))
open('leaflet.html', 'w').write(geoleaflet.html(g)) # Create visualization.

下面提供了另一个用法示例(下面的用法已弃用,但仍受支持):

import geojson
import geoql
import geoleaflet
import requests

url = 'https://raw.githubusercontent.com/Data-Mechanics/geoql/master/examples/'

# Boston ZIP Codes regions.
z = geojson.loads(requests.get(url + 'example_zips.geojson').text, encoding="latin-1")

# Extract of street data.
g = geojson.loads(requests.get(url + 'example_extract.geojson').text, encoding="latin-1")

g = geoql.features_properties_null_remove(g)
g = geoql.features_tags_parse_str_to_dict(g)
g = geoql.features_keep_by_property(g, {"highway": {"$in": ["residential", "secondary", "tertiary"]}})
g = geoql.features_keep_within_radius(g, (42.3551, -71.0656), 0.75, 'miles') # Within 0.75 of Boston Common.
g = geoql.features_keep_intersecting_features(g, z) # Only those entries found in a Boston ZIP Code regions.
g = geoql.features_node_edge_graph(g) # Converted into a graph with nodes and edges.
open('example_extract.geojson', 'w').write(geojson.dumps(g))
open('leaflet.html', 'w').write(geoleaflet.html(g)) # Create visualization.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
带truezip的java拆分zip   java Spring,AppEngine:在AppEngine的数据源中添加postgresql url   java Android coverflow   java以编程方式创建复合过滤器,以在log4j 2中定义多个过滤器   java jpa eclipselink异常[eclipselink 4002]   中的java WordNet数据库目录相对路径。罐子   java无法在Spring Boot 2/3中显示登录的用户   java Onetomany:未找到联接表错误   java数据模型演化   java方法在类型列表中添加的(对象)不适用于参数(int)意味着什么?   用java打印两个数组   java SNMP4J发送从不超时   java添加/删除联系人(EditText)+类别(SpinnerBox),可以根据需要动态添加/删除多个联系人   语句和PreparedStatement之间的java差异   java在运行作为JAR归档文件分发的项目时加载图像等资源   来自应用程序或外部服务器的java Cron作业   多线程Java并发:并发添加和清除列表项   java更改单元测试的私有方法行为