Comments (4)
It isn't losing any edges. The plot_figure_ground
function handles graph construction and plotting in a very specific way to maintain a precise equal-aspect perspective, bounding box, and plotting figure. If you want to overlay another image on top of it, you need to make sure they're created the same way so that they match up, pixel-for-pixel.
First, create your figure-ground diagrams and save to a png file:
import osmnx as ox
from IPython.display import Image
%matplotlib inline
ox.config(log_console=True, use_cache=True)
location_point = (51.05660,3.721500)
dist = 525
network_type = 'walk'
img_folder = 'images'
extension = 'png'
size = 300
def make_plot(place, point, network_type='drive', bldg_color='orange', dpi=90,
dist=805, default_width=4, street_widths=None):
gdf = ox.buildings_from_point(point=point, distance=dist)
gdf_proj = ox.project_gdf(gdf)
fig, ax = ox.plot_figure_ground(point=point, dist=dist, network_type=network_type, default_width=default_width,
street_widths=street_widths, save=False, show=False, close=True)
fig, ax = ox.plot_buildings(gdf_proj, fig=fig, ax=ax, color=bldg_color, set_bounds=False,
save=True, show=False, close=True, filename=place, dpi=dpi)
place = 'gante'
make_plot(place, location_point, network_type=network_type, default_width=3, street_widths={'primary':3}, dist=dist)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)
Then, create a new graph around the same area and plot it the exact same way that plot_figure_ground
would:
G = ox.graph_from_point(location_point, distance=dist*1.2, distance_type='bbox', network_type=network_type,
simplify=False, truncate_by_edge=True)
G = ox.simplify_graph(G, strict=False)
G = ox.project_graph(G)
bbox_proj = ox.bbox_from_point(location_point, dist, project_utm=True)
fig, ax = ox.plot_graph(G, bbox=bbox_proj, fig_height=8, margin=0, axis_off=True, equal_aspect=True, bgcolor='w',
node_size=30, node_color='g', node_zorder=2, edge_linewidth=3, edge_color='m',
show=False, save=True, close=True, filename='new', file_format='png', dpi=90)
You now have two png files saved. Now if you overlay the second image file on top of the first, they will match up, pixel-for-pixel:
from osmnx.
Thank you very much.
It is possible to save G (the graph of roads) as a shapefile and still match the building footprint?
I have tried with
G = ox.graph_from_point(location_point, distance=dist*1.2, distance_type='bbox', network_type=network_type, simplify=False, truncate_by_edge=True)
G1 = ox.simplify_graph(G, strict=False)
ox.save_graph_shapefile(G1, filename='false')
but the result is different that the footprint image.
I would need the roads in shp format.
Thank you for your time and help.
Regards
from osmnx.
The png file format is a raster data format, but shapefiles are a vector data format. Overlaying them and getting them to line up will entirely be up to the software with which you overlay them (i.e., not an OSMnx issue). In general, it's probably easiest to match things up if they're both raster or both vector (though this certainly isn't a hard and fast rule). If you want to do everything as (vector) shapefiles, you can download the building footprints then save as a shapefile -- for an example, see cell 4 in this notebook. Then download the graph of roads and save as a shapefile. If you then open these two shapefiles as layers in a GIS (or whatever software that can handle them), they will line up properly.
from osmnx.
Thank you very much
from osmnx.
Related Issues (20)
- Node Identification within Buffer Zone (if buffer was to be implemented) HOT 1
- PermissionError [ErrNo 13] when connecting to localhost using the latest docker image HOT 2
- Contributing guidelines link nowhere HOT 2
- Document usage limitations HOT 10
- UnicodeDecodeError in graph_from_xml on Windows Installations HOT 4
- Calling graph_from_place("Alaska", network_type="drive") throws GEOSException: TopologyException HOT 4
- Vasu HOT 1
- Unable to plot superimposed image HOT 1
- street networks graphs not working HOT 3
- AttributeError: module 'osmnx' has no attribute 'clean_intersections' HOT 2
- Removal of inner_polygons from outer_polygons (creation of holes), creates maximum one hole. HOT 5
- Include parking space data in nodes HOT 7
- Fill missing values with most common value on similar roads HOT 4
- OSMnx 2.0 Migration Guide HOT 3
- Add junction/intersection types to nodes HOT 6
- Support directed bearing/orientation distributions and plots HOT 5
- Support loading and/or merging multiple networks HOT 5
- [Meta] Enable Discussions tab on this GitHub repo HOT 1
- Further API streamlining for v2 HOT 2
- _bearings_distribution: apply weight during histogram HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osmnx.