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
A bot that tweets info and location map for new bicycle parking added to OpenStreetMap within a GeoJSON boundary.

Bike parking tweepy bot app A twitter bot app that searches for bicycle parking added to OpenStreetMap. Relies on AWS Lambda/S3, Python3, Tweepy, Flas

Angelo Trivisonno 1 Dec 19, 2021
A simple reverse geocoder that resolves a location to a country

Reverse Geocoder This repository holds a small web service that performs reverse geocoding to determine whether a user specified location is within th

4 Dec 25, 2021
A Python package for delineating nested surface depressions from digital elevation data.

Welcome to the lidar package lidar is Python package for delineating the nested hierarchy of surface depressions in digital elevation models (DEMs). I

Qiusheng Wu 166 Jan 03, 2023
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
Record railway train route profile with GNSS tools

Train route profile recording with GNSS technology based on ARDUINO platform Project target Develop GNSS recording tools based on the ARDUINO platform

tomcom 1 Jan 01, 2022
pure-Python (Numpy optional) 3D coordinate conversions for geospace ecef enu eci

Python 3-D coordinate conversions Pure Python (no prerequistes beyond Python itself) 3-D geographic coordinate conversions and geodesy. API similar to

Geospace code 292 Dec 29, 2022
Replace MSFS2020's bing map to google map

English verison here 中文 免责声明 本教程提到的方法仅用于研究和学习用途。我不对使用、拓展该教程及方法所造成的任何法律责任和损失负责。 背景 微软模拟飞行2020的地景使用了Bing的卫星地图,然而卫星地图比较老旧,很多地区都是几年前的图设置直接是没有的。这种现象在全球不同地区

hesicong 272 Dec 24, 2022
Hapi is a Python library for building Conceptual Distributed Model using HBV96 lumped model & Muskingum routing method

Current build status All platforms: Current release info Name Downloads Version Platforms Hapi - Hydrological library for Python Hapi is an open-sourc

Mostafa Farrag 15 Dec 26, 2022
Script that allows to download data with satellite's orbit height and create CSV with their change in time.

Satellite orbit height ◾ Requirements Python = 3.8 Packages listen in reuirements.txt (run pip install -r requirements.txt) Account on Space Track ◾

Alicja Musiał 2 Jan 17, 2022
Centroids as a Service

Centroids! This application reads a valid geojson FeatureCollection and returns a valid geojson FeatureColleciton of centroids. In the output: All pro

Lyzi Diamond 20 Aug 29, 2021
A Django application that provides country choices for use with forms, flag icons static files, and a country field for models.

Django Countries A Django application that provides country choices for use with forms, flag icons static files, and a country field for models. Insta

Chris Beaven 1.2k Jan 03, 2023
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
A public data repository for datasets created from TransLink GTFS data.

TransLink Spatial Data What: TransLink is the statutory public transit authority for the Metro Vancouver region. This GitHub repository is a collectio

Henry Tang 3 Jan 14, 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
Pure python WMS

Ogcserver Python WMS implementation using Mapnik. Depends Mapnik = 0.7.0 (and python bindings) Pillow PasteScript WebOb You will need to install Map

Mapnik 130 Dec 28, 2022
Raster processing benchmarks for Python and R packages

Raster processing benchmarks This repository contains a collection of raster processing benchmarks for Python and R packages. The tests cover the most

Krzysztof Dyba 13 Oct 24, 2022
A Python tool to display geolocation information in the traceroute.

IP2Trace Python IP2Trace Python is a Python tool allowing user to get IP address information such as country, region, city, latitude, longitude, zip c

IP2Location 22 Jan 08, 2023
gpdvega is a bridge between GeoPandas and Altair that allows to seamlessly chart geospatial data

gpdvega gpdvega is a bridge between GeoPandas a geospatial extension of Pandas and the declarative statistical visualization library Altair, which all

Ilia Timofeev 49 Jul 25, 2022
Create Siege configuration files from Cloud Optimized GeoTIFF.

cogeo-siege Documentation: Source Code: https://github.com/developmentseed/cogeo-siege Description Create siege configuration files from Cloud Optimiz

Development Seed 3 Dec 01, 2022
Streamlit Component for rendering Folium maps

streamlit-folium This Streamlit Component is a work-in-progress to determine what functionality is desirable for a Folium and Streamlit integration. C

Randy Zwitch 224 Dec 30, 2022