样本数据:
CREATE TABLE poly_and_multipoly (
"id" SERIAL NOT NULL PRIMARY KEY,
"name" char(1) NOT NULL,
"the_geom" geometry NOT NULL
);
-- add data, A is a polygon, B is a multipolygon
INSERT INTO poly_and_multipoly (name, the_geom) VALUES (
'A', 'POLYGON((7.7 3.8,7.7 5.8,9.0 5.8,7.7 3.8))'::geometry
), (
'B',
'MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)), ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))'::geometry
);
Run Code Online (Sandbox Code Playgroud)
我有一个多边形和多边形的表格,我正在尝试使用ST_Azimuth计算表格中外环的内角(即没有内环......).有没有办法修改附加的查询以在线串的sp和ep上使用ST_Azimuth?
SELECT id, name, ST_AsText( ST_MakeLine(sp,ep) )
FROM
-- …Run Code Online (Sandbox Code Playgroud) 我试图使用shapely的'within'函数来做一个Linestring和一个点文件的'空间连接'(fyi - 点文件是使用线串上的插值函数生成的).问题是 - 什么都没有归还.
我错过了什么?
# this condition is never satisfied
if point.within(line):
# here I write stuff to a file
Run Code Online (Sandbox Code Playgroud)
和
point = POINT (-9763788.9782693591000000 5488878.3678984242000000)
line = LINESTRING (-9765787.998118492 5488940.974948905, -9748582.801636808 5488402.127570709)
Run Code Online (Sandbox Code Playgroud) 我是Shapely的新手(但对此充满热情),最近我发现了一点路障.
我有一个我通过Fiona阅读的多边形shapefile.这个shapefile包含BOTH多边形和多边形项目,我需要为其中的所有坐标(即外部和/或内部)的每个特征构建一个数组.值得注意的是,两个多边形项目具有内环(并且它们是有效的).
我似乎没有问题访问多边形/多边形的外部坐标...但我没有拉内部坐标的任何东西.
我需要在这里采用一种新方法(即LinearRings)......?
def convert_polygons(inFile):
for polys in fiona.open(inFile):
myShape = shape(polys['geometry'])
exterior_poly = 0
interior_poly = 0
if isinstance(myShape, Polygon):
print "yes, I am a polygon"
# count how many points for each interior polygon
try:
interior_poly += len(myShape.interior.coords)
except:
pass
# count how many points for each exterior polygon
exterior_poly += len(myShape.exterior.coords)
geomArray = asarray(myShape.exterior)
print geomArray
print "number of interior points in polygon " + str(interior_poly)
print "number of exterior points in polygon " + str(exterior_poly) …Run Code Online (Sandbox Code Playgroud) 我正在尝试在立交桥的特定区域中构造所有'highway ='方式的查询。我一直默认使用{{bbox}}-但我确实希望按国家/地区进行操作。
我尝试使用'nominatimArea:'而不是{{bbox}},但遇到了解析错误'第8行:预期的解析错误:')'预期-'('找到。
/*
This shows the roads in nepal.
*/
[out:json];
(
way ["highway"~"motorway|trunk|primary|motorway_link|trunk_link|primary_link|unclassified|tertiary|secondary|track|path"]({{nominatimArea:Nepal}});
);
out meta;
>;
out skel qt;
Run Code Online (Sandbox Code Playgroud)
还...如果我尝试这个...我只能(奇怪地)获得一个领域-无法(可能是一团糟?)
/*
This shows the roads in nepal.
*/
[out:json];
(area[name="Nepal"];
way(area) ["highway"~"motorway|trunk|primary|motorway_link|trunk_link|primary_link|unclassified|tertiary|secondary|track|path|residential|service"];
);
out meta;
>;
out skel qt;
Run Code Online (Sandbox Code Playgroud)
返回此一项(不是一个区域)
注:我知道这是一个大的查询-但我真的只需要链接到原始JSON(像这样) -而不是实际的立交桥地图结果。
对于 PYTHON 2.7(我在 3 中使用了编码,现在很困惑......希望得到一些如何在 python 3 中复制此测试的建议......)
\n\n对于欧元字符 (\xe2\x82\xac),我使用此工具查找了其 utf8 十六进制代码点。它说是0x20AC。
\n\n对于 Latin1(再次使用 Python2 2.7),我使用解码来获取其十六进制代码点:
\n\n>>import unicodedata\n>>p=\'\xe2\x82\xac\'\n## notably x80 seems to correspond to [Windows CP1252 according to the link][2]\n>>p.decode(\'latin-1\') \n>>u\'\\x80\'\nRun Code Online (Sandbox Code Playgroud)\n\n然后我对它们都使用了这个 print 语句,这就是我得到的:
\n\n对于 utf8:
\n\n>>> print unichr(0x20AC).encode(\'utf-8\')\n\xc3\xa2\xe2\x80\x9a\xc2\xac\nRun Code Online (Sandbox Code Playgroud)\n\n对于拉丁-1:
\n\n>>> print unichr(0x80).encode(\'latin-1\')\n\xe2\x82\xac\nRun Code Online (Sandbox Code Playgroud)\n\n到底发生了什么?为什么编码对于 utf-8 返回 \'\xc3\xa2\xe2\x80\x9a\xc2\xac\' ?另外...看来Latin1 十六进制代码点可能与它们的utf8 对应代码点不同(我有一位同事认为不同——说Latin1 在这方面就像ASCII)。但不同代码点的存在似乎对我来说另有暗示...然而,python 2.7 读取Windows CP1252 \'x80\'的原因对我来说是一个真正的谜......这是 latin-1 的标准在Python 2.7?
\n