예제 #1
0
    def setup(self):

        test_file_path = mm.datasets.get_path("bubenec")
        self.df_buildings = gpd.read_file(test_file_path, layer="buildings")
        self.df_streets = gpd.read_file(test_file_path, layer="streets")
        self.df_tessellation = gpd.read_file(test_file_path,
                                             layer="tessellation")
        self.df_streets["nID"] = mm.unique_id(self.df_streets)
        self.df_buildings["height"] = np.linspace(10.0, 30.0, 144)
        self.df_tessellation["area"] = self.df_tessellation.geometry.area
        self.df_buildings["area"] = self.df_buildings.geometry.area
        self.df_buildings["fl_area"] = mm.FloorArea(self.df_buildings,
                                                    "height").series
        self.df_buildings["nID"] = mm.get_network_id(self.df_buildings,
                                                     self.df_streets, "nID")
        blocks = mm.Blocks(self.df_tessellation, self.df_streets,
                           self.df_buildings, "bID", "uID")
        self.blocks = blocks.blocks
        self.df_buildings["bID"] = blocks.buildings_id
        self.df_tessellation["bID"] = blocks.tessellation_id
        self.swb = Queen.from_dataframe(self.df_buildings)
        self.sw5 = mm.sw_high(k=5, gdf=self.df_tessellation, ids="uID")
        self.sw3 = mm.sw_high(k=3, gdf=self.df_tessellation, ids="uID")
        self.sws = mm.sw_high(k=2, gdf=self.df_streets)
        nx = mm.gdf_to_nx(self.df_streets)
        nx = mm.node_degree(nx)
        self.nodes, self.edges, W = mm.nx_to_gdf(nx, spatial_weights=True)
        self.swn = mm.sw_high(k=3, weights=W)
예제 #2
0
    def setup_method(self):

        test_file_path = mm.datasets.get_path("bubenec")
        self.df_buildings = gpd.read_file(test_file_path, layer="buildings")
        self.df_streets = gpd.read_file(test_file_path, layer="streets")
        self.df_tessellation = gpd.read_file(test_file_path, layer="tessellation")
        self.df_buildings["height"] = np.linspace(10.0, 30.0, 144)
        self.df_buildings["volume"] = mm.Volume(self.df_buildings, "height").series
        self.df_streets["nID"] = mm.unique_id(self.df_streets)
        self.df_buildings["nID"] = mm.get_network_id(
            self.df_buildings, self.df_streets, "nID"
        )
예제 #3
0
    def setup_method(self):

        test_file_path = mm.datasets.get_path('bubenec')
        self.df_buildings = gpd.read_file(test_file_path, layer='buildings')
        self.df_streets = gpd.read_file(test_file_path, layer='streets')
        self.df_tessellation = gpd.read_file(test_file_path,
                                             layer='tessellation')
        self.df_buildings['height'] = np.linspace(10., 30., 144)
        self.df_buildings['volume'] = mm.volume(self.df_buildings, 'height')
        self.df_streets['nID'] = mm.unique_id(self.df_streets)
        self.df_buildings['nID'] = mm.get_network_id(self.df_buildings,
                                                     self.df_streets, 'uID',
                                                     'nID')
예제 #4
0
    def setup(self):

        test_file_path = mm.datasets.get_path("bubenec")
        self.df_buildings = gpd.read_file(test_file_path, layer="buildings")
        self.df_streets = gpd.read_file(test_file_path, layer="streets")
        self.df_tessellation = gpd.read_file(test_file_path, layer="tessellation")
        self.df_buildings["height"] = np.linspace(10.0, 30.0, 144)
        self.df_buildings["volume"] = mm.Volume(self.df_buildings, "height").series
        self.df_streets["nID"] = mm.unique_id(self.df_streets)
        self.df_buildings["nID"] = mm.get_network_id(
            self.df_buildings, self.df_streets, "nID"
        )
        self.df_buildings["orient"] = mm.Orientation(self.df_buildings).series
        self.df_tessellation["orient"] = mm.Orientation(self.df_tessellation).series
        self.sw = Queen.from_dataframe(self.df_tessellation, ids="uID")
        self.swh = mm.sw_high(k=3, gdf=self.df_tessellation, ids="uID")
        self.swb = Queen.from_dataframe(self.df_buildings, ids="uID")
예제 #5
0
    def setup_method(self):

        test_file_path = mm.datasets.get_path('bubenec')
        self.df_buildings = gpd.read_file(test_file_path, layer='buildings')
        self.df_streets = gpd.read_file(test_file_path, layer='streets')
        self.df_tessellation = gpd.read_file(test_file_path,
                                             layer='tessellation')
        self.df_streets['nID'] = mm.unique_id(self.df_streets)
        self.df_buildings['height'] = np.linspace(10., 30., 144)
        self.df_tessellation['area'] = self.df_tessellation.geometry.area
        self.df_buildings['area'] = self.df_buildings.geometry.area
        self.df_buildings['fl_area'] = mm.floor_area(self.df_buildings,
                                                     'height')
        self.df_buildings['nID'] = mm.get_network_id(self.df_buildings,
                                                     self.df_streets, 'uID',
                                                     'nID')
        self.df_buildings, self.df_tessellation, self.blocks = mm.blocks(
            self.df_tessellation, self.df_streets, self.df_buildings, 'bID',
            'uID')
예제 #6
0
    def setup_method(self):

        test_file_path = mm.datasets.get_path("bubenec")
        self.df_buildings = gpd.read_file(test_file_path, layer="buildings")
        self.df_streets = gpd.read_file(test_file_path, layer="streets")
        self.df_tessellation = gpd.read_file(test_file_path, layer="tessellation")
        self.df_streets["nID"] = mm.unique_id(self.df_streets)
        self.df_buildings["height"] = np.linspace(10.0, 30.0, 144)
        self.df_tessellation["area"] = self.df_tessellation.geometry.area
        self.df_buildings["area"] = self.df_buildings.geometry.area
        self.df_buildings["fl_area"] = mm.FloorArea(self.df_buildings, "height").series
        self.df_buildings["nID"] = mm.get_network_id(
            self.df_buildings, self.df_streets, "nID"
        )
        blocks = mm.Blocks(
            self.df_tessellation, self.df_streets, self.df_buildings, "bID", "uID"
        )
        self.blocks = blocks.blocks
        self.df_buildings["bID"] = blocks.buildings_id
        self.df_tessellation["bID"] = blocks.tessellation_id
gpd.__version__, mm.__version__, matplotlib.__version__, sns.__version__, np.__version__, sp.__version__, shapely.__version__

# In[3]:

polys = [
    Polygon([(10, 10), (20, 10), (20, 20), (10, 20)]),
    Polygon([(30, 10), (40, 10), (40, 20), (30, 20)]),
    Polygon([(10, 30), (20, 30), (20, 40), (10, 40)]),
    Polygon([(20, 30), (30, 30), (30, 40), (20, 40)]),
    Polygon([(30, 30), (40, 30), (40, 40), (30, 40)]),
]

# In[4]:

gdf = gpd.GeoDataFrame(geometry=polys)
gdf['uID'] = mm.unique_id(gdf)
retain = gdf.copy()

# In[5]:

sns.set_style('whitegrid')
sns.set_context(context='paper', font_scale=1, rc=None)

# In[6]:

f, ax = plt.subplots(figsize=(10, 10))
gdf.plot(ax=ax)
sns.despine(left=True, bottom=True)
#plt.savefig('tesdiag_0.svg')

# In[7]:
예제 #8
0
import geopandas as gpd
import momepy as mm

tess = gpd.read_file('files/prg.gpkg', layer='queen')
blg = gpd.read_file('files/prg.gpkg', layer='buildings')

streets = gpd.read_file('files/streets.gpkg', layer='streets')

streets['nID'] = mm.unique_id(streets)

blg['nID'] = mm.get_network_id(blg, streets, 'uID', 'nID', 150)
tess = tess.merge(blg[['uID', 'nID']], on='uID', how='left')

snapped = mm.snap_street_network_edge(streets, blg, 20, tess, 120)

blocks, blg['bID'], tess['bID'] = mm.blocks(tess, snapped, blg, 'bID', 'uID')

tess.to_file('files/elements.gpkg', layer='tessellation', driver='GPKG')
blg.to_file('files/elements.gpkg', layer='buildings', driver='GPKG')
blocks.to_file('files/elements.gpkg', layer='blocks', driver='GPKG')
streets.to_file('files/elements.gpkg', layer='streets', driver='GPKG')