gboeing / osmnx

OSMnx is a Python package to easily download, model, analyze, and visualize street networks and other geospatial features from OpenStreetMap.
https://osmnx.readthedocs.io
MIT License
4.85k stars 824 forks source link

Adding other highway types to street_widths dict in osmnx.plot.plot_figure_ground, not appearing in map #1060

Closed tydonk closed 1 year ago

tydonk commented 1 year ago

Contributing guidelines

Documentation

Existing issues

What operating system and Python version are you using?

macOS Ventura 13.1 / Python 3.11.5

What OSMnx version are you using?

1.6.0

Environment packages and versions

affine                    2.4.0              pyhd8ed1ab_0    conda-forge
attrs                     23.1.0             pyh71513ae_1    conda-forge
aws-c-auth                0.7.3                hab8b942_3    conda-forge
aws-c-cal                 0.6.2                hb406d48_0    conda-forge
aws-c-common              0.9.0                hb547adb_0    conda-forge
aws-c-compression         0.2.17               he70778a_2    conda-forge
aws-c-event-stream        0.3.2                hcf14f3f_0    conda-forge
aws-c-http                0.7.12               he297698_1    conda-forge
aws-c-io                  0.13.32              h3c776e5_2    conda-forge
aws-c-mqtt                0.9.5                h83b98fe_1    conda-forge
aws-c-s3                  0.3.14               h24e141d_3    conda-forge
aws-c-sdkutils            0.1.12               he70778a_1    conda-forge
aws-checksums             0.1.17               he70778a_1    conda-forge
aws-crt-cpp               0.23.0               h04fc39a_5    conda-forge
aws-sdk-cpp               1.10.57             h0092a47_21    conda-forge
blosc                     1.21.4               hc338f07_0    conda-forge
boost-cpp                 1.78.0               h9ed8d21_3    conda-forge
branca                    0.6.0              pyhd8ed1ab_0    conda-forge
brotli                    1.0.9                h1a8c8d9_9    conda-forge
brotli-bin                1.0.9                h1a8c8d9_9    conda-forge
brotli-python             1.0.9           py311ha397e9f_9    conda-forge
bzip2                     1.0.8                h3422bc3_4    conda-forge
c-ares                    1.19.1               hb547adb_0    conda-forge
ca-certificates           2023.7.22            hf0a4a13_0    conda-forge
cairo                     1.16.0            h1e71087_1016    conda-forge
certifi                   2023.7.22          pyhd8ed1ab_0    conda-forge
cfitsio                   4.3.0                hca87796_0    conda-forge
charset-normalizer        3.2.0              pyhd8ed1ab_0    conda-forge
click                     8.1.7           unix_pyh707e725_0    conda-forge
click-plugins             1.1.1                      py_0    conda-forge
cligj                     0.7.2              pyhd8ed1ab_1    conda-forge
contourpy                 1.1.0           py311he4fd1f5_0    conda-forge
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
expat                     2.5.0                hb7217d7_1    conda-forge
fiona                     1.9.4           py311h0e2296b_0    conda-forge
folium                    0.14.0             pyhd8ed1ab_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.14.2               h82840c6_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
fonttools                 4.42.1          py311heffc1b2_0    conda-forge
freetype                  2.12.1               hd633e50_1    conda-forge
freexl                    1.0.6                h1a8c8d9_1    conda-forge
gdal                      3.7.1           py311h354944d_7    conda-forge
geopandas                 0.13.2             pyhd8ed1ab_1    conda-forge
geopandas-base            0.13.2             pyha770c72_1    conda-forge
geos                      3.12.0               h13dd4ca_0    conda-forge
geotiff                   1.7.1               h00e2a8a_11    conda-forge
gettext                   0.21.1               h0186832_0    conda-forge
giflib                    5.2.1                h1a8c8d9_3    conda-forge
hdf4                      4.2.15               h8111dcc_6    conda-forge
hdf5                      1.14.2          nompi_h3aba7b3_100    conda-forge
icu                       72.1                 he12128b_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
importlib-metadata        6.8.0              pyha770c72_0    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
joblib                    1.3.2              pyhd8ed1ab_0    conda-forge
json-c                    0.17                 h40ed0f5_0    conda-forge
kealib                    1.5.1                h47b5e36_5    conda-forge
kiwisolver                1.4.5           py311he4fd1f5_0    conda-forge
krb5                      1.21.2               h92f50d5_0    conda-forge
lcms2                     2.15                 hd835a16_1    conda-forge
lerc                      4.0.0                h9a09cb3_0    conda-forge
libaec                    1.0.6                hb7217d7_1    conda-forge
libarchive                3.6.2                h82b9b87_1    conda-forge
libblas                   3.9.0           17_osxarm64_openblas    conda-forge
libbrotlicommon           1.0.9                h1a8c8d9_9    conda-forge
libbrotlidec              1.0.9                h1a8c8d9_9    conda-forge
libbrotlienc              1.0.9                h1a8c8d9_9    conda-forge
libcblas                  3.9.0           17_osxarm64_openblas    conda-forge
libcurl                   8.2.1                hc52a3a8_0    conda-forge
libcxx                    16.0.6               h4653b0c_0    conda-forge
libdeflate                1.18                 h1a8c8d9_0    conda-forge
libedit                   3.1.20191231         hc8eb9b7_2    conda-forge
libev                     4.33                 h642e427_1    conda-forge
libexpat                  2.5.0                hb7217d7_1    conda-forge
libffi                    3.4.2                h3422bc3_5    conda-forge
libgdal                   3.7.1                hdf35568_7    conda-forge
libgfortran               5.0.0           12_3_0_hd922786_1    conda-forge
libgfortran5              12.3.0               ha3a6a3e_1    conda-forge
libglib                   2.76.4               h24e9cb9_0    conda-forge
libiconv                  1.17                 he4db4b2_0    conda-forge
libjpeg-turbo             2.1.5.1              h1a8c8d9_0    conda-forge
libkml                    1.3.0             h41464e4_1015    conda-forge
liblapack                 3.9.0           17_osxarm64_openblas    conda-forge
libnetcdf                 4.9.2           nompi_h8b962ec_110    conda-forge
libnghttp2                1.52.0               hae82a92_0    conda-forge
libopenblas               0.3.23          openmp_hc731615_0    conda-forge
libpng                    1.6.39               h76d750c_0    conda-forge
libpq                     15.4                 hcea71ed_0    conda-forge
librttopo                 1.1.0               h667cd51_14    conda-forge
libspatialindex           1.9.3                hbdafb3b_4    conda-forge
libspatialite             5.0.1               h6193c13_28    conda-forge
libsqlite                 3.43.0               hb31c410_0    conda-forge
libssh2                   1.11.0               h7a5bd25_0    conda-forge
libtiff                   4.5.1                h23a1a89_1    conda-forge
libwebp-base              1.3.1                hb547adb_0    conda-forge
libxcb                    1.15                 hf346824_0    conda-forge
libxml2                   2.11.5               he3bdae6_0    conda-forge
libzip                    1.10.1               ha0bc3c6_0    conda-forge
libzlib                   1.2.13               h53f4e23_5    conda-forge
llvm-openmp               16.0.6               h1c12783_0    conda-forge
lz4-c                     1.9.4                hb7217d7_0    conda-forge
lzo                       2.10              h642e427_1000    conda-forge
mapclassify               2.5.0              pyhd8ed1ab_1    conda-forge
markupsafe                2.1.3           py311heffc1b2_0    conda-forge
matplotlib-base           3.7.2           py311h3bc9839_0    conda-forge
munch                     4.0.0              pyhd8ed1ab_0    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
ncurses                   6.4                  h7ea286d_0    conda-forge
networkx                  3.1                pyhd8ed1ab_0    conda-forge
nspr                      4.35                 hb7217d7_0    conda-forge
nss                       3.92                 hc6b9969_0    conda-forge
numpy                     1.25.2          py311hb8f3215_0    conda-forge
openjpeg                  2.5.0                hbc2ba62_2    conda-forge
openssl                   3.1.2                h53f4e23_0    conda-forge
osmnx                     1.6.0              pyhd8ed1ab_0    conda-forge
packaging                 23.1               pyhd8ed1ab_0    conda-forge
pandas                    2.0.3           py311h9e438b8_1    conda-forge
pcre2                     10.40                hb34f9b4_0    conda-forge
pillow                    10.0.0          py311h095fde6_0    conda-forge
pip                       23.2.1             pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               h27ca646_0    conda-forge
platformdirs              3.10.0             pyhd8ed1ab_0    conda-forge
pooch                     1.7.0              pyha770c72_3    conda-forge
poppler                   23.08.0              h16d8c84_0    conda-forge
poppler-data              0.4.12               hd8ed1ab_0    conda-forge
postgresql                15.4                 h00cd704_0    conda-forge
proj                      9.2.1                h8fdea58_0    conda-forge
pthread-stubs             0.4               h27ca646_1001    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyproj                    3.6.0           py311h280d66e_1    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.11.5          h47c9636_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-tzdata             2023.3             pyhd8ed1ab_0    conda-forge
python_abi                3.11                    3_cp311    conda-forge
pytz                      2023.3             pyhd8ed1ab_0    conda-forge
rasterio                  1.3.8           py311h6456264_0    conda-forge
readline                  8.2                  h92ec313_1    conda-forge
requests                  2.31.0             pyhd8ed1ab_0    conda-forge
rtree                     1.0.1           py311hd698ff7_2    conda-forge
scikit-learn              1.3.0           py311hf0b18b8_0    conda-forge
scipy                     1.11.2          py311h93d07a4_0    conda-forge
setuptools                68.1.2             pyhd8ed1ab_0    conda-forge
shapely                   2.0.1           py311h7089352_2    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
snappy                    1.1.10               h17c5cce_0    conda-forge
snuggs                    1.4.7                      py_0    conda-forge
sqlite                    3.43.0               h203b68d_0    conda-forge
threadpoolctl             3.2.0              pyha21a80b_0    conda-forge
tiledb                    2.16.3               hc77a09f_1    conda-forge
tk                        8.6.12               he1e0b03_0    conda-forge
typing-extensions         4.7.1                hd8ed1ab_0    conda-forge
typing_extensions         4.7.1              pyha770c72_0    conda-forge
tzcode                    2023c                h1a8c8d9_0    conda-forge
tzdata                    2023c                h71feb2d_0    conda-forge
urllib3                   2.0.4              pyhd8ed1ab_0    conda-forge
wheel                     0.41.2             pyhd8ed1ab_0    conda-forge
xerces-c                  3.2.4                h68f8447_2    conda-forge
xorg-libxau               1.0.11               hb547adb_0    conda-forge
xorg-libxdmcp             1.1.3                h27ca646_0    conda-forge
xyzservices               2023.7.0           pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h57fd34a_0    conda-forge
zipp                      3.16.2             pyhd8ed1ab_0    conda-forge
zlib                      1.2.13               h53f4e23_5    conda-forge
zstd                      1.5.5                h4f39d0f_0    conda-forge

How did you install OSMnx?

Other (describe below)

Problem description

Trying to add additional values to highway key in street_widths dict in osmnx.plot.plot_figure_ground but they are not appearing on the map.

street_widths_xs = { "motorway": 0.75, "motorway_link": 0.75, "trunk": 0.5, "trunk_link": 0.5, "primary": 0.5, "primary_link": 0.5, "secondary": 0.25, "secondary_link": 0.25, "tertiary": 0.25, "tertiary_link": 0.25, "unclassified": 0.25, "residential": 0.25, "living_street": 0.25, "service": 0.1, "pedestrian": 0.1, "track": 0.1, "footway": 0.1, "steps": 0.1, "path": 0.1, }

Below is the map output: Screenshot 2023-09-15 at 2 23 47 PM

Below is the map in OSM using "Query Features". The red line is listed as a residential road Screenshot 2023-09-15 at 2 24 37 PM

Complete minimal reproducible example

# datetime object containing current date and time
now = datetime.now()

# dd/mm/YY H:M:S
dt_string = now.strftime("%m-%d-%Y_%H-%M-%S")

ox.settings.log_console=True
ox.settings.use_cache=False

street_widths_xs = {
    "motorway": 0.75,
    "motorway_link": 0.75,
    "trunk": 0.5,
    "trunk_link": 0.5,
    "primary": 0.5,
    "primary_link": 0.5,
    "secondary": 0.25,
    "secondary_link": 0.25,
    "tertiary": 0.25,
    "tertiary_link": 0.25,
    "unclassified": 0.25,
    "residential": 0.25,
    "living_street": 0.25,
    "service": 0.1,
    "pedestrian": 0.1,
    "track": 0.1,
    "footway": 0.1,
    "steps": 0.1,
    "path": 0.1,
    }

land_tags = {
    #'aeroway': True,
    #'amenity': True,
    'building': True,
    #'highway': True,
    #'historic': True,
    #'landuse': 'industrial',
    #'leisure': 'park',
    #'man_made': 'bridge',
    #'military': True,
    #'natural': 'coastline',
    #'place': True,
    #'shop': True,
    #'sport': True,
    #'tourism': True
    #'waterway': True
    }

bgcolor="#000000"
edge_color="#FFFFFF"
bldg_color="#FD3030"
place = 'sd'
point = (32.7362, -117.1129)
dist = 8000
dpi = 1000

# Helper function to get square street networks, building footprints, and plot them
def make_plot(place, point, dist=dist, dpi=dpi, network_type='all', default_width=0.25,
                street_widths=street_widths_xs):

    # Get bounding box
    bbox = ox.utils_geo.bbox_from_point(point, dist=dist)
    # Get land features using land_tags dictionary
    land = ox.geometries.geometries_from_point(center_point=point, tags=land_tags, dist=dist)
    # Get water bodies using water_tags dictionary
    water = ox.geometries.geometries_from_point(center_point=point, tags=water_tags, dist=dist)
    # Plot figure-ground diadram of streets
    fig, ax = ox.plot.plot_figure_ground(point=point, dist=dist, network_type=network_type,
                                    default_width=default_width, street_widths=street_widths,
                                    edge_color=edge_color, save=False, show=False, close=True, bgcolor=bgcolor)

    # Plot land footprint
    fig, ax = ox.plot.plot_footprints(land, ax=ax, color=bldg_color, bbox=bbox, dpi=dpi,
                                save=True, show=False, close=True,
                                filepath="{}-dist{}-dpi{}-{}.png".format(place,dist,dpi,dt_string))

make_plot(place, point, dist)
gboeing commented 1 year ago

Thanks for using OSMnx! Your code isn't runnable (multiple undefined variables), so I cannot troubleshoot this. However, there doesn't appear to be any bug. Per the contributing guidelines, please ask usage questions on StackOverflow.