python - Getting maximum and minimum of OpenStreetMap map -
i downloaded 1 single city corresponding openstreetmap data. want maximum , minimum values latitude , longitude. how can that?
my approach following:
import osmread osm #... def _parse_map(self): geo = [(entity.lat, entity.lon) entity in osm.parse_file('map.osm') if isinstance(entity, osm.node)] return max(geo[0]), min(geo[0]), max(geo[1]), min(geo[1])
but when print these values don't think right. when downloaded area openstreetmap site had white area indicating region exporting. , area got minimum , maximum values latitude , longitude. , these values arent fitting ones simple script.
what doing wrong?
return max(geo[0]), min(geo[0]), max(geo[1]), min(geo[1])
you taking extrema of first , second element of geo
. geo
list of 2-tuples. first element geo[0]
2-tuple consisting of entity.lat
, entity.lon
first node. therefore choosing min/max of latitude , longitude 1 node.
if want feed first (second) element of each tuple in list aggregate function, have choose these. example generator:
return max(x[0] x in geo), min(x[0] x in geo), max(x[1] x in geo), min(x[1] x in geo)
Comments
Post a Comment