0

我正在尝试使用 GeoAlchemy 查询 PostGIS 表以返回该点所在的行。我有一点,我正在使用来自自然地球的时区 shapefile 。我已经尝试了以下方法,但它只返回查询而不是行项。

class TimeZonePoly(Base):
    __tablename__ = 'time_zone_poly_grid_exp'
    __table_args__ = {'autoload': True}

def PointInside(PostGIS_Table, Lat, Lon):
    point = func.ST_GeographyFromText('POINT({} {})'.format(Lon, Lat))
    return session.query(PostGIS_Table).filter(func.ST_Contains(PostGIS_Table.geom, point))
     

row = PointInside(TimeZonePoly, 47, -2)
print(row)

它返回以下内容:

SELECT time_zone_poly_grid_exp.id AS time_zone_poly_grid_exp_id, ST_AsEWKB(time_zone_poly_grid_exp.geom) AS time_zone_poly_grid_exp_geom, time_zone_poly_grid_exp.objectid AS time_zone_poly_grid_exp_objectid, time_zone_poly_grid_exp.scalerank AS time_zone_poly_grid_exp_scalerank, time_zone_poly_grid_exp.featurecla AS time_zone_poly_grid_exp_featurecla, time_zone_poly_grid_exp.name AS time_zone_poly_grid_exp_name, time_zone_poly_grid_exp.map_color6 AS time_zone_poly_grid_exp_map_color6, time_zone_poly_grid_exp.map_color8 AS time_zone_poly_grid_exp_map_color8, time_zone_poly_grid_exp.note AS time_zone_poly_grid_exp_note, time_zone_poly_grid_exp.zone AS time_zone_poly_grid_exp_zone, time_zone_poly_grid_exp.utc_format AS time_zone_poly_grid_exp_utc_format, time_zone_poly_grid_exp.time_zone AS time_zone_poly_grid_exp_time_zone, time_zone_poly_grid_exp.iso_8601 AS time_zone_poly_grid_exp_iso_8601, time_zone_poly_grid_exp.places AS time_zone_poly_grid_exp_places, time_zone_poly_grid_exp.dst_places AS time_zone_poly_grid_exp_dst_places, time_zone_poly_grid_exp.tz_name1st AS time_zone_poly_grid_exp_tz_name1st, time_zone_poly_grid_exp.tz_namesum AS time_zone_poly_grid_exp_tz_namesum 
FROM time_zone_poly_grid_exp 
WHERE ST_Contains(time_zone_poly_grid_exp.geom, ST_GeographyFromText(%(ST_GeographyFromText_1)s))

看起来这是正确的陈述,我就是无法得到结果!

4

0 回答 0