Talk:Python/Script for finding nearby nodes

From OpenStreetMap Wiki
Jump to: navigation, search

Some hints for processing the results

notes for clumping the matching nodes in GRASS GIS using raster modules:

(from within a NZTM (EPSG:2193) location, imported as on the main side of this wiki page)

# set the region zoom to the NZ area, 500m resolution:
GRASS> g.region n=6250000 s=4700000 w=1050000 e=2100000 res=500

# perform binning; new raster map is count of points in each cell
GRASS> v.out.ascii matching_nodes | r.in.xyz in=- out=matches_count method=n

# wipe out cells with no points
GRASS> r.null matches_count setnull=0

# create a virtual raster where all cells contain category 1
GRASS> r.reclass in=matches_count out=matches_mask << EOF
* = 1
EOF

# assign each contiguous clump of cell its own category number
GRASS> r.clump in=matches_mask out=matches_clump

# export as a list of URLs to visit
#  (the uniq skip-chars thing is a brittle hack ..
#   any ideas short of a full r.reclass + 'g.region zoom=' loop by category?)
GRASS> r.out.xyz wharf_matches_clump --quiet | sort -n -k 3 -t '|' | \
   uniq --skip-chars=16 | cut -f1,2 -d'|' | m.proj -do --quiet | \
   cut -f1 -d' ' | sed -e 's|^|http://www.openstreetmap.org/?lon=|' \
    -e 's|\t|\&lat=|' -e 's/$/\&zoom=16/'