Platform for building statistical models of cities and regions

Related tags

Geolocationurbansim
Overview

UrbanSim

Latest Version Build Status Test Coverage

UrbanSim is a platform for building statistical models of cities and regions. These models help forecast long-range patterns in real estate development, demographics, and related outcomes, under various policy scenarios.

This urbansim Python library is a core component. It contains tools for statistical estimation and simulation; domain-specific logic about housing markets, household relocation, and other processes; and frameworks and utilities for assembling a model.

How it works

Operational UrbanSim models begin with detailed data about a particular region, and then estimate and validate a system of interconnected model components. Full models draw on a number of libraries: not just urbansim, but also Orca for task orchestration, Synthpop for population synthesis, Pandana for network analysis, and so on. Collectively, these make up the Urban Data Science Toolkit (UDST).

UrbanSim models are used by public agencies, consultancies, and researchers in dozens of cities around the U.S. and world. The core platform is open source, but many operational models make use of additional cloud-hosted model building and visualization tools provided by UrbanSim Inc.

Learn More

Installation

  • pip install urbansim
  • conda install urbansim --channel conda-forge

Technical documentation

Comments
  • High Level Interface

    High Level Interface

    I'm starting to put down some ideas for the high level interface to urbansim, you can see some sketches here: https://gist.github.com/jiffyclub/0bb253757547fbc14add. There isn't a huge difference between the three sketches there now, but I'll keep thinking about things and probably our dialogue will spur some ideas all around.

    Let me know what looks good, what's missing, what's on your wishlist for this, etc.

    opened by jiffyclub 20
  • Allow sampling of alternatives during prediction

    Allow sampling of alternatives during prediction

    It's kind of limited sampling, not something you could use during a location choice model. Alternatives may show up as available for more than one chooser and alternatives may show up more than once for a single chooser.

    opened by jiffyclub 18
  • Installing troubles

    Installing troubles

    I cant get conda to install urbansim > 1.3, Win 10, Py 2.7 64 bit

    IPythonNotebookScratch>conda config --add channels synthicity
    Skipping channels: synthicity, item already exists
    IPythonNotebookScratch>conda install urbansim
    Using Anaconda Cloud api site https://api.anaconda.org
    Fetching package metadata: ......
    Solving package specifications: ................................
    Package plan for installation in environment C:\Anaconda2:
    
    The following NEW packages will be INSTALLED:
    
        urbansim: 1.3-py27_0
    
    Proceed ([y]/n)?n
    IPythonNotebookScratch>conda install -c https://conda.anaconda.org/synthicity urbansim
    Using Anaconda Cloud api site https://api.anaconda.org
    Fetching package metadata: ........
    Solving package specifications: ................................
    Package plan for installation in environment C:\Anaconda2:
    
    The following NEW packages will be INSTALLED:
    
        urbansim: 1.3-py27_0
    
    Proceed ([y]/n)?n
    

    What am I doing wrong here?

    opened by Eh2406 16
  • Supply and Demand Corrections

    Supply and Demand Corrections

    @fscottfoti, this implements the supply/demand comparison and adjustment we'd specced out. Very simple, straight comparison of (probabilities * len(choosers)).groupby(alternatives[col].values).sum() / alternatives[col].value_counts() with adjustments done across 5 iterations, capped at 0.75-1.25 fractional change per iteration.

    opened by jiffyclub 16
  • transition model updates

    transition model updates

    Made some changes to the transition model. These include:

    1. Update _updated_linked_table method to use pandas merge:

    I was hitting a performance bottle-neck when adding a large number of agents (and therefore linked agents). I was adding ~70k agents and 194K linked agents and this was taking around ~34 seconds. Changing the code to use the merge reduced this to ~4 seconds.

    1. Add ability to control to a count provided by an 'accounting' column:

    This was a feature that MAG had added to the old opus code. For example, we may want to sample from households but the control we want to hit exactly is household population. I added a new sampling file to the utilities folder to handle most of the heavy lifting w/ the idea that maybe this functionality could be of use outside the transition model as well. Changes were then made to add and remove rows methods and each of the transition classes to accommodate this.

    I've tested this, and everything seems to be working fine. But I get that this is addressing pretty core functionality so if you are not comfortable bringing this in right now I'm cool w/ mirroring the transition file (something like mag_transition?). We could also leave in this in our specific urbansim implementation but I thought it might be of use to other agencies.

    opened by bridwell 16
  • Fix sample rows no replace

    Fix sample rows no replace

    This addresses feedback when the accounting total is not met (#178) and also providing probability distributions to influence the sample (#149).

    To obtain feedback, set the return_status argument to True, and this will return both the sampled rows and the status. If False, then only the sampled rows will be returned. This is still the default, so as to not break any existing calls.

    To provide sampling probabilities, set the prob_column argument to the name of the column in the data frame containing the weights or probabilities. These values will be normalized so they sum to 1, if they do not already.

    The logic for sampling with accounting but without replacement has been changed to hopefully be more robust.

    opened by bridwell 15
  • No feedback if iteration does not reach exact result in utils.sampling.sample_rows

    No feedback if iteration does not reach exact result in utils.sampling.sample_rows

    Function utils.sampling.sample rows includes a loop which shall converge to an exact pick of samples. In some cases, this loop cannot converge. Example:

    import pandas as pd
    import urbansim.utils.sampling
    df = pd.DataFrame({'tot': [2,2,2]})
    sample = urbansim.utils.sampling.sample_rows(total=3, data=df, replace=False, accounting_columns='tot')
    sample.sum()  # = 2 and not = 3 as expected
    

    Even if an exact pick is possible, the random permutation l.51 causes a further problem. If the values needed for an exact pick are at the head of the randomized list sample_idx, they are not available in the loop to adjust for an inexact pick, the loop cannot converge. This aspect depends on the random seed, so it can make integration tests fail randomly.

    Suggested solution: there should be some feedback from the sample_rows function whenever convergence to an exact pick is not achieved. The caller may use this information if he wishes. In this way a more robust test suite can be obtained.

    opened by moritz-kirmse-forcity 14
  • Cache scope

    Cache scope

    This adds a cache_scope option to the table, column, and injectable decorators that allow results to be automatically cleared from the cache at set points. The options are 'step', 'iter', and 'forever'. Items with scope 'step' are cleared after every model is run, items with scope 'iter' are cleared at the end of every model year, and things with scope 'forever' are never automatically cleared.

    This removes the need for table_source so that has been removed. The equivalent is now to use cache_scope='forever'.

    I waffled a little bit on using 'forever' or 'simulation' for the long-lived scope. With a scope of 'simulation' it'd make sense to clear it at the end of the simulation, with 'forever' it'd be best to never clear it. I'm up for either one, anyone have an opinion?

    opened by jiffyclub 14
  • Injectable Memoization

    Injectable Memoization

    This enables something like this:

    @sim.injectable(autocall=False, memoize=True)
    def my_utility_func(x, y, z):
        return x + y + z
    
    @sim.column()
    def my_col(another_col, my_utility_func):
        result = my_utility_func(1, 2, 3)
        return another_col * result
    

    And if you call my_utility_func again with the input of 1, 2, 3 you'll get back the cached result instead of re-doing the calculation.

    Memoization requires autocall=False and that function inputs always be hashable. The memoization cache follows the same rules as other caching, so you can use cache_scope=, sim.clear_cache, sim.disable_cache, and sim.enable_cache as usual.

    opened by jiffyclub 12
  • Account class

    Account class

    For tracking money. Right now it has .add_transaction(amount, subaccount, metadata), .add_transactions(transactions), and .to_frame() methods. You can access the balance or list of transactions via the .balance and .transactions attributes, respectively. What else does it need?

    opened by jiffyclub 10
  • use `pd.Int64Index()`

    use `pd.Int64Index()`

    • return pd.DataFrame with pd.Int64Index() index in remove_rows()
    • add assert_empty_int64index() to use with test_tgrtransition_with_accounting()

    I tried changing as little code as possible.

    Note that the failed build is due to changes in pandas (possibly 0.18 (or >=0.17.1)), as commented here.

    Alternatively, for the test_*remove*all() tests at least, the check_index_type option in pdt.assert_frame_equal() can be set to False. This isn't guaranteed to fix everything.

    opened by juanshishido 9
  • Deprecation in yaml conversion

    Deprecation in yaml conversion

    In Pandas 1.2+, pandas.Index.to_native_types() is deprecated, raising warnings like the following:

    Screen_Shot_2021-02-09_at_11 52 05_AM1

    This comes up in code that serializes data to yaml for storage and later reloading.

    urbansim/utils/yamlio.py#L48

    The replacement suggested in the message doesn't sound as general-purpose, but maybe it would work if Pandas is able to convert string representations of ints and floats back to the appropriate data type. Another option could be to use to_json().

    pandas.Index.to_native_types() pandas.Series.astype() pandas.Series.to_json()

    opened by smmaurer 0
  • Functionality of this repo

    Functionality of this repo

    Hey guys, I'm just going through this code and noticing, it doesn't seem to have the same functionality as what's been implemented in the UrbanSim Cloud Platform. Where can I find the files being used in the UrbanSim Cloud Platform? Are they also open source?

    Also, I have found an old version of the SqFtProForma.py file and it seems to have more functionality than the file in this repo. Was this file not working? Is this urbansim repo old?

    Old file was here https://github.com/UDST/developer/blob/master/developer/sqftproforma.py

    opened by eweyftw 1
  • No pandas tour

    No pandas tour

    Description of the bug

    Wes McKinney's intro to pandas is no more available http://udst.github.io/urbansim/gettingstarted.html#pandas

    Vimeo link points to nowhere https://vimeo.com/59324550

    opened by abitrolly 0
  • Update tests to support PyTest 4.0 +

    Update tests to support PyTest 4.0 +

    Some of our unit test syntax has been deprecated and removed in recent versions of PyTest.

    For example, tests that directly called the df() fixture defined in test_mnl.py#L82 were raising errors when I worked on PR #222.

    This shouldn't be too hard to fix, but will require going through and setting up some of the test data in alternative ways. It doesn't seem especially high-priority, though.

    For now, I've pinned pytest at v3.10 in the Travis and AppVeyor scripts.

    Type: maintenance 
    opened by smmaurer 0
  • Transition model, preserve index name?

    Transition model, preserve index name?

    When running transition model, the resulting data frame loses the index name (I'm guessing because of the concat). Is this worth preserving? This would be a simple fix, but not sure if it would break existing implementations.

    Type: bug 
    opened by bridwell 2
  • Transition model: option for relaxing conditions when filtering agents to be sampled from

    Transition model: option for relaxing conditions when filtering agents to be sampled from

    The transition model will not work well if the subset of agents to be sampled from is very small or even empty. Thus, an option of relaxing the filtering conditions (as present in Opus) would be very useful (e.g. if there are not enough households of the given characteristics within the given city, sample from the corresponding county or the whole region).

    If nothing else, an option to use a user-defined callback function would help, together with letting the model to access the model configuration. It would replace/extend the filter_table call: https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/transition.py#L305

    opened by hanase 2
Releases(v3.2)
  • v3.2(May 15, 2020)

    • Improved installation and compatibility
    • Support for Pandas 1.0
    • Various improvements and bug fixes
    • Note that active development of certain UrbanSim components has moved to stand-alone libraries in UDST: Developer, Choicemodels, UrbanSim Templates
    Source code(tar.gz)
    Source code(zip)
  • v3.1.1(May 9, 2017)

  • v3.1.0(May 9, 2017)

Owner
Urban Data Science Toolkit
Open source projects supporting urban spatial analysis, simulation, and visualization
Urban Data Science Toolkit
Computer Vision in Python

Mahotas Python Computer Vision Library Mahotas is a library of fast computer vision algorithms (all implemented in C++ for speed) operating over numpy

Luis Pedro Coelho 792 Dec 20, 2022
Google maps for Jupyter notebooks

gmaps gmaps is a plugin for including interactive Google maps in the IPython Notebook. Let's plot a heatmap of taxi pickups in San Francisco: import g

Pascal Bugnion 747 Dec 19, 2022
Track International space station with python

NASA-ISS-tracker Track International space station with python Modules import json import turtle import urllib.request import time import webbrowser i

Nikhil Yadav 8 Aug 12, 2021
Python project to generate Kerala's distrcit level panchayath map.

Kerala-Panchayath-Maps Python project to generate Kerala's distrcit level panchayath map. As of now, geojson files of Kollam and Kozhikode are added t

Athul R T 2 Jan 10, 2022
a Geolocator made in python

Geolocator A Geolocator made in python ✨ Features locates ur location using ur ip thats it! 💁‍♀️ How to use first download the locator.py file instal

Portgas D Ace 1 Oct 27, 2021
Cloud Optimized GeoTIFF creation and validation plugin for rasterio

rio-cogeo Cloud Optimized GeoTIFF (COG) creation and validation plugin for Rasterio. Documentation: https://cogeotiff.github.io/rio-cogeo/ Source Code

216 Dec 31, 2022
Enable geospatial data mining through Google Earth Engine in Grasshopper 3D, via its most recent Hops component.

AALU_Geo Mining This repository is produced for a masterclass at the Architectural Association Landscape Urbanism programme. Requirements Rhinoceros (

4 Nov 16, 2022
A short term landscape evolution using a path sampling method to solve water and sediment flow continuity equations and model mass flows over complex topographies.

r.sim.terrain A short-term landscape evolution model that simulates topographic change for both steady state and dynamic flow regimes across a range o

Brendan Harmon 7 Oct 21, 2022
Expose a GDAL file as a HTTP accessible on-the-fly COG

cogserver Expose any GDAL recognized raster file as a HTTP accessible on-the-fly COG (Cloud Optimized GeoTIFF) The on-the-fly COG file is not material

Even Rouault 73 Aug 04, 2022
Simulation and Parameter Estimation in Geophysics

Simulation and Parameter Estimation in Geophysics - A python package for simulation and gradient based parameter estimation in the context of geophysical applications.

SimPEG 390 Dec 15, 2022
Django model field that can hold a geoposition, and corresponding widget

django-geoposition A model field that can hold a geoposition (latitude/longitude), and corresponding admin/form widget. Prerequisites Starting with ve

Philipp Bosch 324 Oct 17, 2022
3D extension built off of shapely to make working with geospatial/trajectory data easier in python.

PyGeoShape 3D extension to shapely and pyproj to make working with geospatial/trajectory data easier in python. Getting Started Installation pip The e

Marc Brittain 5 Dec 27, 2022
Geographic add-ons for Django REST Framework. Maintained by the OpenWISP Project.

django-rest-framework-gis Geographic add-ons for Django Rest Framework - Mailing List. Install last stable version from pypi pip install djangorestfra

OpenWISP 981 Jan 03, 2023
Python Data. Leaflet.js Maps.

folium Python Data, Leaflet.js Maps folium builds on the data wrangling strengths of the Python ecosystem and the mapping strengths of the Leaflet.js

6k Jan 02, 2023
Tile Map Service and OGC Tiles API for QGIS Server

Tiles API Add tiles API to QGIS Server Tiles Map Service API OGC Tiles API Tile Map Service API - TMS The TMS API provides these URLs: /tms/? to get i

3Liz 6 Dec 01, 2021
A toolbox for processing earth observation data with Python.

eo-box eobox is a Python package with a small collection of tools for working with Remote Sensing / Earth Observation data. Package Overview So far, t

13 Jan 06, 2022
Simple CLI for Google Earth Engine Uploads

geeup: Simple CLI for Earth Engine Uploads with Selenium Support This tool came of the simple need to handle batch uploads of both image assets to col

Samapriya Roy 79 Nov 26, 2022
QLUSTER is a relative orbit design tool for formation flying satellite missions and space rendezvous scenarios

QLUSTER is a relative orbit design tool for formation flying satellite missions and space rendezvous scenarios, that I wrote in Python 3 for my own research and visualisation. It is currently unfinis

Samuel Low 9 Aug 23, 2022
A NASA MEaSUREs project to provide automated, low latency, global glacier flow and elevation change datasets

Notebooks A NASA MEaSUREs project to provide automated, low latency, global glacier flow and elevation change datasets This repository provides tools

NASA Jet Propulsion Laboratory 27 Oct 25, 2022
prettymaps - A minimal Python library to draw customized maps from OpenStreetMap data.

A small set of Python functions to draw pretty maps from OpenStreetMap data. Based on osmnx, matplotlib and shapely libraries.

Marcelo de Oliveira Rosa Prates 9k Jan 08, 2023