Skip to content

Commit

Permalink
this removes the monkey patching for geocanvas and moves it to dframe…
Browse files Browse the repository at this point in the history
…_explorer

still needs a test for this new function
  • Loading branch information
fscottfoti committed Sep 2, 2014
1 parent 7ef628c commit 8ea9c22
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ install:
- sudo conda init
- sudo conda update --yes conda
- |
conda create -p $HOME/py --yes ipython-notebook jinja2 matplotlib numpy pandas patsy pip scipy statsmodels pandana pytables pytest pyyaml toolz "python=$TRAVIS_PYTHON_VERSION" -c "synthicity"
conda create -p $HOME/py --yes fiona ipython-notebook jinja2 matplotlib numpy pandas patsy pip scipy statsmodels pandana pytables pytest pyyaml shapely toolz "python=$TRAVIS_PYTHON_VERSION" -c "synthicity"
- export PATH=$HOME/py/bin:$PATH
- pip install simplejson bottle
- pip install pytest-cov coveralls pep8
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
packages=find_packages(exclude=['*.tests']),
install_requires=[
'bottle>=0.12.5',
'geopandas>=0.1.0',
'matplotlib>=1.3.1',
'numpy>=1.8.0',
'pandas>=0.13.1',
Expand All @@ -46,6 +45,7 @@
'toolz>=0.7.0'
],
extras_require = {
'pandana': ['pandana>=0.1']
'pandana': ['pandana>=0.1'],
'geopandas': ['geopandas>=0.1.0']
}
)
3 changes: 0 additions & 3 deletions urbansim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@

from .patsypatch import patch_patsy
patch_patsy()

from .geopandaspatch import patch_geopandas
patch_geopandas()
55 changes: 0 additions & 55 deletions urbansim/geopandaspatch.py

This file was deleted.

52 changes: 52 additions & 0 deletions urbansim/maps/dframe_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,55 @@ def start(views,
webbrowser.open("http://%s:%s" % (host, port), new=2)

run(host=host, port=port, debug=True)


def geodataframe_explore(gdf,
dataframe_d=None,
center=None,
zoom=11,
geom_name=None, # from JSON file, use index if None
join_name='zone_id', # from data frames
precision=2,
port=8765,
host='localhost',
testing=False):
"""
This method
"""
try:
import geopandas
except:
raise ImportError("This method requires that geopandas be installed "
"in order to work correctly")

if dataframe_d is None:
dataframe_d = {}

# add the geodataframe
df = pd.DataFrame(gdf)
if geom_name is None:
df[join_name] = df.index
dataframe_d["local"] = df

# need to check if it's already 4326
if gdf.crs != 4326:
self = gdf.to_crs(epsg=4326)

bbox = self.total_bounds
if center is None:
center = [(bbox[1]+bbox[3])/2, (bbox[0]+bbox[2])/2]

self.to_json()

start(
dataframe_d,
center=center,
zoom=zoom,
shape_json=self.to_json(),
geom_name=geom_name, # from JSON file
join_name=join_name, # from data frames
precision=precision,
port=port,
host=host,
testing=testing
)

0 comments on commit 8ea9c22

Please sign in to comment.