Coder Social home page Coder Social logo

geopandas_osm's People

Contributors

jwass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

geopandas_osm's Issues

Installing geopandas_osm

Hi there, I'm trying to figure out how to install geopandas_osm. Is there a conda or pip install option? I found a reference to 'conda install -c derickl geopandas-osm' but this doesn't work for me. Thanks & apologies if I'm missing something obvious!

AttributeError: 'MultiPolygon' object has no attribute 'exterior'

Same sort of error as #4

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-17-4eb7221da34b> in <module>
      3 
      4 # Query for the highways within the `sg_boundary` we obtained earlier from the sg_admin.
----> 5 df2 = geopandas_osm.osm.query_osm('way', sg_boundary, recurse='down', tags='highway')
      6 
      7 # This gives us lots of columns we don't need, so we'll isolate it to the three we do need

G:\Anaconda3\lib\site-packages\geopandas_osm\osm.py in query_osm(typ, bbox, recurse, tags, raw, meta, **kwargs)
     87 
     88     """
---> 89     url = _build_url(typ, bbox, recurse, tags, meta)
     90 
     91     # TODO: Raise on non-200 (or 400-599)

G:\Anaconda3\lib\site-packages\geopandas_osm\osm.py in _build_url(typ, bbox, recurse, tags, meta)
    128             #','.join(str(b) for b in (bbox[1], bbox[0], bbox[3], bbox[2])))
    129         bboxstr = '(poly:"{}")'.format(
--> 130             ' '.join('{c[1]} {c[0]}'.format(c=c) for c in bbox.exterior.coords))
    131 
    132     if meta:

AttributeError: 'MultiPolygon' object has no attribute 'exterior'

HTTPError: HTTP Error 414: Request-URI Too Long

Hi, I get the following error if I run the following code:

import geopandas_osm.osm as osm
import geopandas as gpd

districts=gpd.read_file('data/turin_districts/turin_districts.shp')
districts.crs={'init':'epsg:3003'}
districts=districts.to_crs(epsg=4326)
districts.crs
sansa=districts[districts.DENOM=='San Salvario'].geometry
osm.query_osm('node',sansa[1], recurse='down', tags='highway')
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-94-73ea9ce921fb> in <module>
----> 1 osm.query_osm('node',sansa[1], recurse='down', tags='highway')

~\.conda\envs\gisenv\lib\site-packages\geopandas_osm\osm.py in query_osm(typ, bbox, recurse, tags, raw, meta, **kwargs)
     90 
     91     # TODO: Raise on non-200 (or 400-599)
---> 92     with urlopen(url) as response:
     93         content = response.read()
     94 

~\.conda\envs\gisenv\lib\site-packages\pandas\io\common.py in urlopen(*args, **kwargs)
    139     import urllib.request
    140 
--> 141     return urllib.request.urlopen(*args, **kwargs)
    142 
    143 

~\.conda\envs\gisenv\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    220     else:
    221         opener = _opener
--> 222     return opener.open(url, data, timeout)
    223 
    224 def install_opener(opener):

~\.conda\envs\gisenv\lib\urllib\request.py in open(self, fullurl, data, timeout)
    529         for processor in self.process_response.get(protocol, []):
    530             meth = getattr(processor, meth_name)
--> 531             response = meth(req, response)
    532 
    533         return response

~\.conda\envs\gisenv\lib\urllib\request.py in http_response(self, request, response)
    639         if not (200 <= code < 300):
    640             response = self.parent.error(
--> 641                 'http', request, response, code, msg, hdrs)
    642 
    643         return response

~\.conda\envs\gisenv\lib\urllib\request.py in error(self, proto, *args)
    567         if http_err:
    568             args = (dict, 'default', 'http_error_default') + orig_args
--> 569             return self._call_chain(*args)
    570 
    571 # XXX probably also want an abstract factory that knows when it makes

~\.conda\envs\gisenv\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
    501         for handler in handlers:
    502             func = getattr(handler, meth_name)
--> 503             result = func(*args)
    504             if result is not None:
    505                 return result

~\.conda\envs\gisenv\lib\urllib\request.py in http_error_default(self, req, fp, code, msg, hdrs)
    647 class HTTPDefaultErrorHandler(BaseHandler):
    648     def http_error_default(self, req, fp, code, msg, hdrs):
--> 649         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    650 
    651 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 414: Request-URI Too Long

Loop over all ways in "df"

I would like to calculate the perimeter length of all ways (with tag man_made=) inside my boundary
length = df.geometry.length

But I'm always getting
AttributeError: 'LineString' object has no attribute 'exterior'

when using your example code and my Sarnia.geojson as input:

with open('Sarnia.geojson') as f:
    data = json.load(f)

poly = shapely.geometry.shape(data['features'][0]['geometry'])
df = geopandas_osm.osm.query_osm('way', poly, recurse='down', tags='man_made')

Error after 0.7.55 overpass api update

Api requests fails after recent (may 2018) overpass api update with code '400 BadRequest: Element "print" cannot be subelement of element "union"'

Also discussed here: openstreetmap/openstreetmap-website#1843

Can be fixed by adding additional semicolon at line 137 of osm.py file:
query = '({typ}{bbox}{queries};{recurse};);out {meta};'.format(

Your library was very helpfull, so i hope it will help others as well)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.