Given a routable network table constructed by completing the guide at http://anitagraser.com/2011/02/07/a-beginners-guide-to-pgrouting/, how can I get an accurate list of all roads that are within a ring between 5 and 10 miles of a randomly selected start point?
The contents of the routing network table were derived from a shapefile of all roads in the NG 911 system available for download at my state’s GIS data repository
Using Python and raw SQL, I’m doing the following:
query_select_ring = """
SELECT * FROM road_network
WHERE st_distance_sphere(geom,st_pointfromtext('{0}', 4326)) < 10 * 1609.344
AND st_distance_sphere(geom, st_pointfromtext('{0}', 4326)) >= 5 * 1609.344;"""
The value use for st_pointfromtext
is the result of the query
SELECT st_astext(st_startpoint)FROM road_network WHERE gid = {0};
where gid
is the ID of a randomly selected row.
My issue is that on every ocassion the ring query has run, the values returned appear to have no rhyme or reason for their inclusion in the result set, with some points being within 2 miles of the start and others being 50-80 miles.
How can I refine the query to return an accurate result set of all roads that are within 5 miles inclusive and 10 miles exclusive of a randomly selected start point?
For testing data, I’ve uploaded the files to my google drive
https://drive.google.com/file/d/0B86VfDOuBm2IcWgwRXhCTGlkVXM/view?usp=sharing
https://drive.google.com/file/d/0B86VfDOuBm2IZ29aRjFQS3RlZVE/view?usp=sharing
One is the dump file of 5000 rows (of approximately 140K) and the second is the schema ddl output resulting from
pg_dump --schema-only -t road_network geo > pgis_schema.ddl