Aller au contenu

pymdu.geometric

pymdu.geometric

pymdu.geometric

Building

Building

Building(
    filepath_shp=None,
    output_path=None,
    defaultStoreyHeight=3,
    set_crs=None,
)

Bases: IgnCollect

Class to collect the Building data.

This class provides a method to read and process building data from a shapefile or GeoJSON file. It also calculates the mean height of the buildings, as well as their area and centroid.

Args: filepath_shp (str): The file path to the shapefile. output_path (str): The output path for the processed data. If not provided, a default temporary path will be used. defaultStoreyHeight (float): The default height of each storey. set_crs (int): The CRS (Coordinate Reference System) to be set.

Example

2025-06-05T10:55:04.108249 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt

import pymdu.geometric.Building as Building

buildings = Building(output_path='./')
buildings.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
buildings = buildings.run()
buildings.to_gdf().plot(
    ax=plt.gca(),
    edgecolor='black',
    column='hauteur',
    legend=True,
    legend_kwds={'label': 'Hauteur', 'orientation': 'vertical'},
)
Todo
  • For module TODOs

Cadastre

Cadastre

Cadastre(output_path=None)

Bases: IgnCollect

Class representing the Cadastre data collection.

output_path (str): The output path for the processed data. If not provided, a default temporary path will be used.
Example

2025-06-05T10:55:05.494564 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import pymdu.geometric.Cadastre as Cadastre

cadastre = Cadastre(output_path='./')
cadastre.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
cadastre = cadastre.run()
gdf = cadastre.to_gdf()
gdf.plot(ax=plt.gca(), edgecolor='black', column='idu')
Todo
  • For module TODOs

Cosia

Cosia

Cosia(output_path=None, template_raster_path=None)

Bases: GeoCore

A class used to collect and process Cosia data.

This class provides methods for importing GeoPackage files into a PostgreSQL database, retrieving geodata from specified departments within a bounding box, creating landcover rasters, and overlapping with pedestrian areas. It also includes functionalities for creating trees and their positions based on the Cosia data.

ATTRIBUTE DESCRIPTION
cosia_keys

A dictionary containing Cosia keys.

TYPE: dict

output_path

The output path for processed data.

TYPE: str

template_raster_path

The default height of each storey.

TYPE: str

gdf

The GeoDataFrame containing the geodata.

TYPE: GeoDataFrame

PARAMETER DESCRIPTION
output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

template_raster_path

The default height of each storey.

TYPE: str DEFAULT: None

Example

```python exec="false" source="tabbed-right" html="1" tabs="Source code|Plot" import matplotlib.pyplot as plt

plt.clf() # markdown-exec: hide cosia = Cosia(output_path='./') cosia.bbox = [-1.15643, 46.16123, -1.15127, 46.16378] cosia_gdf = cosia.run().to_gdf() cosia_gdf.plot(color=cosia_gdf['color']) cosia_gdf.plot(ax=plt.gca()) from io import StringIO # markdown-exec: hide

buffer = StringIO() # markdown-exec: hide plt.gcf().set_size_inches(10, 5) # markdown-exec: hide plt.savefig(buffer, format='svg', dpi=199) # markdown-exec: hide print(buffer.getvalue()) # markdown-exec: hide ```

Todo
  • For module TODOs

create_trees_from_cosia

create_trees_from_cosia(
    geom_col="geometry",
    height=6.0,
    type=2,
    trunk_zone=3.0,
    diameter=4.0,
    resolution=13,
)

Dem

Dem

Dem(output_path=None)

Bases: IgnCollect

Class to collect the Dem data

PARAMETER DESCRIPTION
output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

Example:

2025-06-05T10:55:07.908952 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt

import pymdu.geometric.Dem as Dem
import rasterio
import rasterio.plot

dem = Dem(output_path='./')
dem.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
ign_dem = dem.run()
fig, ax = plt.subplots(figsize=(15, 15))
raster = rasterio.open('DEM.tif')
rasterio.plot.show(raster, ax=ax, cmap='viridis')

Todo
  • For module TODOs

DetectionUrbanTypes

DetectionUrbanTypes

DetectionUrbanTypes(output_path=None)

Bases: GeoCore

PARAMETER DESCRIPTION
output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

Example

2025-06-05T10:55:27.431671 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import pymdu.geometric.DetectionUrbanTypes as DetectionUrbanTypes

detection = DetectionUrbanTypes(output_path='./')
detection.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
detection = detection.run()
gdf = detection.to_gdf()
gdf.plot(
    ax=plt.gca(),
    column='cluster',
    categorical=True,
    figsize=(16, 16),
    legend=True,
)
Todo
  • For module TODOs

Dpe

Dpe

Dpe(output_path=None, num_department=None, columns=None)

Bases: GeoCore

Class to collect the Cadastre data

PARAMETER DESCRIPTION
output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

Example

2025-06-05T10:55:29.515776 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import pymdu.geometric.Dpe as Dpe
import pymdu.geometric.Building as Building

dpe = Dpe()
dpe.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
dpe_gdf = dpe.run().to_gdf()
table_color = dpe.table_color
buildings = Building(output_path='./')
buildings.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
buildings_gdf = buildings.run().to_gdf()
# color_mapping = {"category1": "green", "category2": "red"}
ax = dpe_gdf.plot(
    ax=plt.gca(),
    edgecolor='black',
    categorical=True,
    column='classe_consommation_energie',
    legend=True,
    color=dpe_gdf['color'],
)
patches = [
    mpatches.Patch(color=info[1], label=info[0])
    for info in table_color.values()
]
plt.legend(
    handles=patches,
    loc='upper right',
    title='Etiquette DPE',
    bbox_to_anchor=(1.1, 1.0),
)
buildings_gdf.plot(ax=ax, edgecolor='black', alpha=0.5)
Todo
  • For module TODOs

Dxf2Shp

create_circle

create_circle(center, radius, num_segments=36)

Créer un polygone approximant un cercle.

:param center: Tuple (x, y) représentant les coordonnées du centre. :param radius: Rayon du cercle. :param num_segments: Nombre de segments pour approximer le cercle. :return: Géométrie OGR de type POLYGON.

calculate_centroid

calculate_centroid(geometry)

Calculer le centroïde ou le point moyen d'une géométrie MultiLineString25D.

:param geometry: Géométrie OGR de type wkbMultiLineString25D. :return: Tuple (x, y) représentant le centroïde.

calculate_circumscribed_circle_radius

calculate_circumscribed_circle_radius(geometry)

Calculer le rayon du cercle circonscrit à une géométrie donnée.

:param geometry: Géométrie OGR (par ex., wkbMultiLineString25D). :return: Rayon du cercle circonscrit.

dxf_to_polygon_shp

dxf_to_polygon_shp(input_dxf, output_shp, encoding='UTF-8')

Convertir des polygones d'un fichier DXF en un fichier SHP.

:param input_dxf: Chemin vers le fichier DXF d'entrée. :param output_shp: Chemin vers le fichier shapefile de sortie. :param encoding: Character encoding le fichier DXF

dxf_to_polygon_shp2

dxf_to_polygon_shp2(input_dxf, output_shp, tree_shp)

Convertir des polygones d'un fichier DXF en deux fichiers SHP : - output_shp pour les polygones généraux. - tree_shp pour les arbres identifiés.

:param input_dxf: Chemin vers le fichier DXF d'entrée. :param output_shp: Chemin vers le fichier shapefile de sortie général. :param tree_shp: Chemin vers le fichier shapefile des arbres.

dxf_to_cosia_and_weighted_layers

dxf_to_cosia_and_weighted_layers(
    input_shp_dxf,
    output_shp_gdf,
    bbox_coords=None,
    bbox_crs="EPSG:4326",
    encoding="UTF-8",
)

Convertir des layers d'un fichier DXF en layers Cosia avec poids : :param input_shp_dxf: Chemin vers le fichier SHP d'entrée. :param output_shp: Chemin vers le fichier shapefile de sortie :param bbox_coords: choisir le taille :param bbox_crs: le crs du bbox_coords :param encoding: encoding de le fichier SHP

Iris

Iris

Iris(output_path=None)

Bases: IgnCollect

PARAMETER DESCRIPTION
output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

Example

2025-06-05T10:55:30.216701 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import pymdu.geometric.Iris as Iris

iris = Iris(output_path='./')
iris.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
iris = iris.run()
gdf = iris.to_gdf()
gdf.plot(ax=plt.gca())
Todo
  • For module TODOs

Isochrone

Isochrone

Isochrone(output_path=None, poi=None, write_geojson=False)

Bases: GeoCore

PARAMETER DESCRIPTION
output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

poi

The point of interest.

TYPE: dict DEFAULT: None

write_geojson

If True, the processed data will be written to a GeoJSON file.

TYPE: bool DEFAULT: False

Example

2025-06-05T10:55:35.311136 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import contextily as cx
import pymdu.geometric.Isochrone as Isochrone

poi = {'lon': -1.1491, 'lat': 46.1849}
iso = Isochrone(poi=poi)
iso.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
iso.run()
iso_in_gdf, iso_out_gdf = iso.to_gdf()
t = 15  # 15 minutes
ax = iso_in_gdf.loc[[t]].plot(
    alpha=0.25, color='black', figsize=(8, 8), label='in'
)
ax = iso_out_gdf.loc[[t]].plot(alpha=0.25, color='b', ax=ax, label='out')
cx.add_basemap(
    ax,
    source=cx.providers.CartoDB.VoyagerNoLabels,
    crs=iso_out_gdf.crs.to_string(),
)
_ = plt.plot(iso.poi_lam93.x, iso.poi_lam93.y, marker='o', color='red', alpha=1)
_ = plt.axis('off')
Todo
  • For module TODOs

create_isochrones

create_isochrones(
    coords,
    tt_col="tt_out",
    x_col="x_2154",
    y_col="y_2154",
    steps_m=[10, 20, 30],
    ratio=0.3,
    allow_holes=False,
)

Create isochrones from travel time data.

Parameters

coords : pandas.DataFrame DataFrame containing coordinates and travel time data. tt_col : str, optional Name of the column containing travel time data. The default is "tt_out". x_col : str, optional Name of the column containing x-coordinates. The default is "x_2154". y_col : str, optional Name of the column containing y-coordinates. The default is "y_2154". steps_m : list of int, optional List of travel times in minutes for which to create isochrones. The default is [10, 20, 30]. ratio : float, optional Ratio of concavity for the isochrones. The default is 0.3. allow_holes : bool, optional Whether to allow holes in the isochrones. The default is False.

Returns

gdf : geopandas.GeoDataFrame GeoDataFrame containing the isochrones as polygons.

compute_slope staticmethod

compute_slope(triangle_att)

triangle_att must be [tail_z, head_z, length]

IsochroneIGN

IsochroneIGN

IsochroneIGN(
    output_path=None,
    resource="bdtopo-valhalla",
    point=(2.337306, 48.849319),
    costValue=300,
    costType="time",
    set_crs=None,
)

Bases: IgnCollect

Class to collect the Building data

PARAMETER DESCRIPTION
output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

resource

The resource to use.

TYPE: str DEFAULT: 'bdtopo-valhalla'

point

Coordonnées d'une position ponctuelle. C'est le point à partir duquel seront fait les calculs. Il devra être exprimé dans le CRS, par défaut, de la ressource (voir le paramètre 'crs' dans le GetCapabilities).

TYPE: tuple DEFAULT: (2.337306, 48.849319)

costValue

The cost value. Valeur du coût utilisé pour le calcul. Les valeurs disponibles et la valeur par défaut utilisées sont présentes dans le GetCapabilities. On pourra, par exemple, préciser une distance ou un temps, selon l'optimisation choisie. L'unité dépendra aussi des paramètres distanceUnit et timeUnit.

TYPE: int DEFAULT: 300

costType

The cost type. Type du coût utilisé pour le calcul. Les valeurs disponibles et la valeur par défaut utilisées sont présentes dans le GetCapabilities. On pourra, par exemple, préciser une distance ou un temps, selon l'optimisation choisie. L'unité dépendra aussi des paramètres distanceUnit et timeUnit

TYPE: str DEFAULT: 'time'

set_crs

The CRS (Coordinate Reference System) to be set.

TYPE: int DEFAULT: None

Example
Traceback (most recent call last):
  File "/Users/Boris/miniforge3/envs/pymdu/lib/python3.11/site-packages/markdown_exec/_internal/formatters/python.py", line 71, in _run_python
    exec_python(code, code_block_id, exec_globals)
  File "/Users/Boris/miniforge3/envs/pymdu/lib/python3.11/site-packages/markdown_exec/_internal/formatters/_exec_python.py", line 8, in exec_python
    exec(compiled, exec_globals)  # noqa: S102
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<code block: n8>", line 8, in <module>
    isochroneIGN = isochroneIGN.run()
                    ^^^^^^^^^^^^^^^^^^
  File "/Users/Boris/Documents/TIPEE/pymdu_public/pymdu/geometric/IsochroneIGN.py", line 102, in run
    gdf = gpd.read_file(file, driver='GeoJSON')
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Boris/miniforge3/envs/pymdu/lib/python3.11/site-packages/geopandas/io/file.py", line 317, in _read_file
    return _read_file_pyogrio(
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/Boris/miniforge3/envs/pymdu/lib/python3.11/site-packages/geopandas/io/file.py", line 577, in _read_file_pyogrio
    return pyogrio.read_dataframe(path_or_bytes, bbox=bbox, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Boris/miniforge3/envs/pymdu/lib/python3.11/site-packages/pyogrio/geopandas.py", line 275, in read_dataframe
    result = read_func(
             ^^^^^^^^^^
  File "/Users/Boris/miniforge3/envs/pymdu/lib/python3.11/site-packages/pyogrio/raw.py", line 198, in read
    return ogr_read(
           ^^^^^^^^^
  File "pyogrio/_io.pyx", line 1293, in pyogrio._io.ogr_read
  File "pyogrio/_io.pyx", line 227, in pyogrio._io.ogr_open
pyogrio.errors.DataSourceError: '/vsimem/pyogrio_72d8efac3f9f4979802decaf9ce00fe2' not recognized as being in a supported file format.; It might help to specify the correct driver explicitly by prefixing the file path with '<DRIVER>:', e.g. 'CSV:path'.
Todo
  • For module TODOs

LandCover

LandCover

LandCover(
    building_gdf=None,
    vegetation_gdf=None,
    water_gdf=None,
    pedestrian_gdf=None,
    cosia_gdf=None,
    dxf_gdf=None,
    output_path=None,
    write_file=True,
)

Bases: GeoCore, BasicFunctions

classdocs rappel de la définition initiale des classes dans Umep Name Code Alb Emis Ts_deg Tstart TmaxLST Roofs(buildings) 2 0.18 0.95 0.58 -9.78 15.0 Dark_asphalt 1 0.18 0.95 0.58 -9.78 15.0 Cobble_stone_2014a 0 0.20 0.95 0.37 -3.41 15.0 Water 7 0.05 0.98 0.00 0.00 12.0 Grass_unmanaged 5 0.16 0.94 0.21 -3.38 14.0 bare_soil 6 0.25 0.94 0.33 -3.01 14.0 Walls 99 0.20 0.90 0.37 -3.41 15.0

PARAMETER DESCRIPTION
building_gdf

gpd.GeoDataFrame = None,

TYPE: GeoDataFrame DEFAULT: None

vegetation_gdf: gpd.GeoDataFrame = None,
water_gdf: gpd.GeoDataFrame = None,
pedestrian_gdf: gpd.GeoDataFrame = None,
cosia_gdf: gpd.GeoDataFrame = None,
dxf_gdf: gpd.GeoDataFrame = None,
output_path: str = None,
write_file: bool = True,
Example

2025-06-05T10:55:47.436970 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

from pymdu.image import geotiff
from pymdu.geometric import Vegetation, Pedestrian, Water, Building, LandCover
from pymdu.geometric.Dem import Dem
from pymdu.commons.BasicFunctions import plot_sol_occupancy
from pymdu.GeoCore import GeoCore

geocore = GeoCore()
geocore.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]

building = Building(output_path="./")
buildings_gdf = building.run().to_gdf()
# building.to_shp(name='buildings')

water = Water(output_path="./")
water_gdf = water.run().to_gdf()
# water.to_shp(name='water')

pedestrian = Pedestrian(output_path="./")
pedestrian_gdf = pedestrian.run().to_gdf()
# pedestrian.to_shp(name='pedestrian')

vegetation = Vegetation(output_path="./", min_area=100)
vegetation_gdf = vegetation.run().to_gdf()
# vegetation.to_shp(name='vegetation')

# cosia_gdf = gpd.read_file("../../demos/demo_cosia_gdf.shp")
# dxf_gdf = gpd.read_f  #
cosia_gdf = None
dxf_gdf = None

landcover = LandCover(
output_path="./",
building_gdf=buildings_gdf,
vegetation_gdf=vegetation_gdf,
water_gdf=water_gdf,
cosia_gdf=cosia_gdf,
dxf_gdf=dxf_gdf,
pedestrian_gdf=pedestrian_gdf,
write_file=False,
)

landcover.run()
# landcover.to_shp(name="landcover")
landcover_gdf = landcover.to_gdf()

fig, ax = plt.subplots(figsize=(10, 10))

if cosia_gdf is not None:
    landcover_gdf.plot(color=landcover_gdf["color"])
    fig_hist = plot_sol_occupancy(cosia_gdf, landcover_gdf)
    fig_hist.show()
else:
    landcover_gdf.plot(ax=plt.gca(), edgecolor="black", column="type")
Todo
  • For module TODOs

create_landcover_from_cosia

create_landcover_from_cosia(
    dst_tif="landcover.tif", template_raster_path=None
)

crée le fichier tif du gdf de couverture du sol COSIA dst_tif: le fichier output

Lcz

Lcz

Lcz(filepath_shp=None, output_path=None, set_crs=None)

Bases: GeoCore

Class to collect the Building data

PARAMETER DESCRIPTION
filepath_shp

The file path to the shapefile.

TYPE: str DEFAULT: None

output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

set_crs

The CRS (Coordinate Reference System) to be set.

TYPE: int DEFAULT: None

Example

2025-06-05T10:55:52.062096 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

import pymdu.geometric.Lcz as Lcz

lcz = Lcz()
lcz_gdf = lcz.run().to_gdf()
lcz.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
table_color = lcz.table_color
fig, ax = plt.subplots(figsize=(10, 10))
lcz_gdf.plot(ax=ax, edgecolor=None, color=lcz_gdf['color'])
patches = [
    mpatches.Patch(color=info[1], label=info[0])
    for info in table_color.values()
]
plt.legend(
    handles=patches,
    loc='upper right',
    title='LCZ Legend',
    bbox_to_anchor=(1.1, 1.0),
)
Todo
  • For module TODOs

Pedestrian

Pedestrian

Pedestrian(filepath_shp=None, output_path=None)

Bases: GeoCore

Class to collect the Pedestrian data

PARAMETER DESCRIPTION
filepath_shp

The file path to the shapefile.

TYPE: str DEFAULT: None

output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

Example

2025-06-05T10:55:52.228825 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import h3pandas

import pymdu.geometric.Pedestrian as Pedestrian

pedestrian = Pedestrian(output_path='./')
pedestrian.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
pedestrian.run()
gdf = pedestrian.to_gdf()
point_arbres = pedestrian.tree_position(
    pedestrian=pedestrian.gdf,
    resolution=11,
    height=6.0,
    type=2,
    trunk_zone=3.0,
)
gdf.plot(ax=plt.gca(), edgecolor='black')
# point_arbres.plot(color='red', markersize=10)
Todo
  • For module TODOs

tree_position staticmethod

tree_position(
    pedestrian,
    resolution=11,
    height=6.0,
    type=2,
    trunk_zone=3.0,
    diameter=4.0,
)
PARAMETER DESCRIPTION
diameter

TYPE: float DEFAULT: 4.0

height

TYPE: float DEFAULT: 6.0

type

TYPE: int DEFAULT: 2

trunk_zone

TYPE: float DEFAULT: 3.0

pedestrian

le geodataframe de la zone piétonne

TYPE: GeoDataFrame

resolution

la résolution pour le découpage hexagonal

TYPE: int DEFAULT: 11

Returns: geodataframe de la position des arbres

Rnb

Rnb

Rnb(output_path=None)

Bases: GeoCore

PARAMETER DESCRIPTION
output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

Example

2025-06-05T10:55:53.742787 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import pymdu.geometric.Building as Building
import pymdu.geometric.Rnb as Rnb

rnb = Rnb(output_path='./')
rnb.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
rnb = rnb.run()
rnb_gdf = rnb.to_gdf()
buildings = Building(output_path='./')
buildings.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
buildings_gdf = buildings.run().to_gdf()
ax = rnb_gdf.plot(ax=plt.gca(), edgecolor='black', color='red')
buildings_gdf.plot(ax=ax, edgecolor='black', alpha=0.5)
Todo
  • For module TODOs

Road

Road

Road(output_path=None)

Bases: IgnCollect

Class to collect the Road data

PARAMETER DESCRIPTION
output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

Example

2025-06-05T10:55:54.954343 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import pymdu.geometric.Road as Road

road = Road(output_path='./')
road.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
road = road.run()
road_gdf = road.to_gdf()
ax = road_gdf.plot(ax=plt.gca(), edgecolor='black', color='red')
Todo
  • For module TODOs

SkyFactor

SkyFactor

SkyFactor(buildings_gdf, elevationFieldname='hauteur')

Bases: GeoCore

classdocs

PARAMETER DESCRIPTION
buildings_gdf

GeoDataFrame of the buildings.

TYPE: GeoDataFrame

elevationFieldname

Name of the elevation field.

TYPE: str DEFAULT: 'hauteur'

Example

2025-06-05T10:56:56.040624 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import pymdu.geometric.SkyFactor as SkyFactor
import pymdu.geometric.Building as Building

building = Building(output_path='./')
buildings_gdf = building.run().to_gdf()
sky_factor = SkyFactor(
    buildings_gdf=buildings_gdf, elevationFieldname='hauteur'
)
sky_factor.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
sky_factor = sky_factor.run()
sky_factor_gdf = sky_factor.to_gdf()
_, basemap = plt.subplots(figsize=(8.26, 8.26))
basemap.set_title('Sky View Factor', fontsize=16)
plt.axis('off')
buildings_gdf.plot(ax=basemap, color='grey')
sky_factor_gdf.plot(
    ax=basemap, column='svf', markersize=8, legend=True, cmap='viridis'
)
plt.legend(loc='upper right', framealpha=0.5)
Todo
  • For module TODOs

UrockFiles

UrockFiles

UrockFiles(
    output_path=None, buildings_gdf=None, trees_gdf=None
)

Bases: GeoCore

classdocs

generate_urock_buildings

generate_urock_buildings(filename_shp='urock_bld.shp')

Returns:

generate_urock_trees

generate_urock_trees(
    filename_shp="urock_trees.shp",
    size=6,
    ID_VEG=5,
    MIN_HEIGHT=2.2,
    MAX_HEIGHT=5.8,
    ATTENUATIO=2.8,
)

Returns:

Vegetation

Vegetation

Vegetation(
    filepath_shp=None,
    output_path=None,
    set_crs=None,
    write_file=False,
    min_area=0,
)

Bases: IgnCollect

Class to collect the Vegetation data

PARAMETER DESCRIPTION
filepath_shp

(str) The path to the shapefile to be processed. If not provided, the data will be read from the input file.

TYPE: str DEFAULT: None

output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

set_crs

(int) The EPSG code to set the CRS of the output file. If not provided, the CRS of the input file will be used.

TYPE: int DEFAULT: None

write_file

(bool) If True, the output file will be written to disk. If False, the output file will be returned.

TYPE: bool DEFAULT: False

min_area

(float) The minimum area of the polygons to be considered as vegetation. If not provided, the minimum area will be set to 0.

TYPE: float DEFAULT: 0

Example

2025-06-05T10:57:02.793973 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import pymdu.geometric.Vegetation as Vegetation

vegetation = Vegetation(output_path='./')
vegetation.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
vegetation = vegetation.run()
gdf = vegetation.to_gdf()
gdf.plot(ax=plt.gca(), edgecolor='black', color='green', alpha=0.5)
Todo
  • For module TODOs

Water

Water

Water(filepath_shp=None, output_path=None, set_crs=None)

Bases: GeoCore

=== Classe qui permet - de construire une reqûete pour interroger l'API de l'IGN - enregistre les données dans le dossier ./demo/ ===

PARAMETER DESCRIPTION
filepath_shp

(str) The path to the shapefile to be processed. If not provided, the data will be read from the input file.

TYPE: str DEFAULT: None

output_path

The output path for the processed data. If not provided, a default temporary path will be used.

TYPE: str DEFAULT: None

set_crs

(int) The EPSG code to set the CRS of the output file. If not provided, the CRS of the input file will be used.

TYPE: int DEFAULT: None

Example

2025-06-05T10:57:03.385947 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import pymdu.geometric.Water as Water

water = Water(output_path='./')
water.bbox = [-1.152704, 46.181627, -1.139893, 46.18699]
water = water.run()
gdf = water.to_gdf()
gdf.plot(ax=plt.gca(), edgecolor='black', color='blue', alpha=0.5)
Todo
  • For module TODOs

pymdu.meteo

pymdu.meteo

pymdu.meteo

Meteo

Meteo

Meteo(output_path=None)

Bases: GeoCore

gen_umep_weather_from_list

gen_umep_weather_from_list(
    listofdays,
    epw_file="LaRochelle_historical_IPSL_bc_type.epw",
    init_weather_file="base_weather.txt",
    compute_night=True,
)

TODO : mieux définir les jours/nuits

PARAMETER DESCRIPTION
listofdays

epw_file

DEFAULT: 'LaRochelle_historical_IPSL_bc_type.epw'

init_weather_file

DEFAULT: 'base_weather.txt'

compute_night

DEFAULT: True

pymdu.physics.umep

pymdu.physics.umep

pymdu.physics.umep

DsmModelGenerator

DsmModelGenerator

DsmModelGenerator(
    working_directory,
    output_filepath_dsm="DSM.tif",
    input_filepath_dem="DEM.tif",
    input_building_shp_path="buildings.shp",
    input_mask_shp_path="mask.shp",
)

Bases: UmepCore

PARAMETER DESCRIPTION
input_solweig_path

The path to the input Solweig file.

TYPE: path

RETURNS DESCRIPTION

None

HeightAspectModelGenerator

HeightAspectModelGenerator

HeightAspectModelGenerator(
    working_directory,
    input_filepath_dsm="DSM.tif",
    output_filepath_aspect="ASPECT.tif",
    output_filepath_height="HEIGHT.tif",
)

Bases: UmepCore

Args:

RETURNS DESCRIPTION

None

SVFModelGenerator

SVFModelGenerator

SVFModelGenerator(
    working_directory,
    input_filepath_dsm="DSM.tif",
    input_filepath_dem="DEM.tif",
    input_filepath_cdsm="CDSM.tif",
    input_filepath_tdsm="TDSM.tif",
    ouptut_filepath_svf="SVF.tif",
)

Bases: UmepCore

Args:

RETURNS DESCRIPTION

None

Solweig

Solweig

Solweig(
    meteo_path,
    output_dir,
    working_directory,
    input_filepath_landcover="landcover.tif",
    input_filepath_dsm="DSM.tif",
    input_filepath_dem="DEM.tif",
    input_filepath_cdsm="CDSM.tif",
    input_filepath_tdsm="TDSM.tif",
    input_filepath_height="HEIGHT.tif",
    input_filepath_aspect="ASPECT.tif",
    input_filepath_shadowmats_npz="shadowmats.npz",
    input_filepath_svf_zip="svfs.zip",
)

Bases: UmepCore

PARAMETER DESCRIPTION
input_solweig_path

The path to the input solweig file.

TYPE: path

meteo_path

The path to the meteo file.

TYPE: path

output_dir

The path to the output directory.

TYPE: path

SurfaceModelGenerator

SurfaceModelGenerator

SurfaceModelGenerator(
    working_directory,
    input_filepath_dsm="DSM.tif",
    input_filepath_dem="DEM.tif",
    input_filepath_tree_shp="trees.shp",
    output_filepath_cdsm="CDSM.tif",
    output_filepath_tdsm="TDSM.tif",
)

Bases: UmepCore

PARAMETER DESCRIPTION
input_solweig_path

The path to the input Solweig file.

TYPE: path

RETURNS DESCRIPTION

None

pymdu.image

pymdu.image

pymdu.image

Lidar

Lidar

Lidar(output_path=None, classification=None)

Bases: GeoCore

PARAMETER DESCRIPTION
building_gdf

gpd.GeoDataFrame = None,

vegetation_gdf

gpd.GeoDataFrame = None,

water_gdf

gpd.GeoDataFrame = None,

pedestrian_gdf

gpd.GeoDataFrame = None,

cosia_gdf

gpd.GeoDataFrame = None,

dxf_gdf

gpd.GeoDataFrame = None,

output_path

str = None,

TYPE: FilePath DEFAULT: None

write_file

bool = True,

Example

2025-06-05T10:57:37.455038 image/svg+xml Matplotlib v3.10.3, https://matplotlib.org/

import matplotlib.pyplot as plt
import matplotlib.patches as mpatches


from shapely.geometry.geo import box
from pyproj import Transformer
import matplotlib.pyplot as plt
import rasterio.plot
from pymdu.image.Lidar import Lidar

lidar = Lidar(
    output_path="./",
    classification=6,
)
lidar.bbox = [-1.154894, 46.182639, -1.148361, 46.186820]
# lidar_gdf = lidar.run().to_gdf()
# # lidar_gdf.plot(ax=plt.gca(), edgecolor='black')
# # plt.show()
# lidar.to_shp(name='LidarTest')

lidar_tif = lidar.to_tif(write_out_file=True)

# Lire les données et les afficher avec rasterio.plot
with lidar_tif.open() as src:
    fig, ax = plt.subplots(figsize=(10, 10))
    rasterio.plot.show(src, ax=ax, title="Lidar CDSM")
Todo
  • For module TODOs

merge_tifs

merge_tifs(input_files, dsm_out, write_out_file=False)

Merge multiple GeoTIFF files into a single GeoTIFF file.

PARAMETER DESCRIPTION
dsm_out

Path to the output GeoTIFF file.

TYPE: FilePath

write_out_file

If True, write the merged GeoTIFF file. Otherwise, return a MemoryFile.

TYPE: bool DEFAULT: False

input_files

List of paths to input GeoTIFF files.

TYPE: list

geotiff

resample_resolution

resample_resolution(
    src_tif=None, dst_tif=None, new_xres=1, new_yres=-1
)

resample resolution the pixel size of the raster.

PARAMETER DESCRIPTION
new_xres

desired resolution in x-direction

TYPE: int DEFAULT: 1

new_yres

desired resolution in y-direction

TYPE: int DEFAULT: -1

save_path

filepath to where the output file should be stored

TYPE: str

Returns: Nothing, it writes a raster file with decreased resolution. :param new_yres: :param new_xres:

reproject

reproject(
    src_tif=None,
    dst_tif=None,
    src_epsg=3857,
    dist_epsg=2154,
)

resample resolution the pixel size of the raster.

PARAMETER DESCRIPTION
new_xres

desired resolution in x-direction

TYPE: int

new_yres

desired resolution in y-direction

TYPE: int

save_path

filepath to where the output file should be stored

TYPE: str

Returns: Nothing, it writes a raster file with decreased resolution. :param new_yres: :param new_xres:

resample_size

resample_size(
    src_tif=None, dst_tif=None, new_width=1, new_height=-1
)

resample size of the raster.

PARAMETER DESCRIPTION
new_width

desired width

TYPE: int DEFAULT: 1

new_height

desired height

TYPE: int DEFAULT: -1

Returns: Nothing, it writes a raster file with decreased resolution. :param save_path: :param new_height: :param new_width:

resample_projection

resample_projection(
    src_tif=None, dst_tif=None, new_epsg=2154
)

resample projection of the raster.

PARAMETER DESCRIPTION
new_epsg

desired epsg

TYPE: int DEFAULT: 2154

save_path

filepath to where the output file should be stored

TYPE: str

Returns: Nothing, it writes a raster file with decreased resolution. :param save_path: :param new_epsg:

toto

toto(src_tif, dst_tif='output.tif')
RETURNS DESCRIPTION
object

raster_to_gdf

raster_to_gdf(src_tif, new_field_name='elevation')
RETURNS DESCRIPTION
object

TYPE: GeoDataFrame

gdf_to_raster

gdf_to_raster(
    gdf,
    dst_tif,
    measurement,
    categorical=False,
    resolution=(-0.03, 0.03),
    raster_file_like=None,
    fill_value=None,
    dtype="float64",
)
PARAMETER DESCRIPTION
dst_tif

measurement

TYPE: str

dtype

DEFAULT: 'float64'

fill_value

DEFAULT: None

gdf

TYPE: GeoDataFrame

categorical

TYPE: bool DEFAULT: False

resolution

TYPE: tuple DEFAULT: (-0.03, 0.03)

raster_file_like

TYPE: str DEFAULT: None

reproject_resample_cropped_raster

reproject_resample_cropped_raster(
    model_file, src_tif, dst_tif="optionnal"
)
PARAMETER DESCRIPTION
model_file

le raster .tif dont les caractéristiques doivent être copiées

input_file

le fichier raster .tif d'entrée

output_file

le du raster .tif nom que l'on souhaite donner à la sortie

tiff_to_jp2

tiff_to_jp2(
    src_tif,
    output="output.jp2",
    openjpeg_base_path="/Users/Boris/anaconda3/envs/pymdu/bin",
)
RETURNS DESCRIPTION
object

rasterize

rasterize

pc_to_dsm builtin

pc_to_dsm()

pc_to_dsm(points: numpy.ndarray[numpy.float64], values: numpy.ndarray[numpy.float64], valid: numpy.ndarray[numpy.int32], xstart: float, ystart: float, xsize: int, ysize: int, resolution: float, radius: int, sigma: float) -> tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray]

Convert point cloud to digital surface model


Generated by MkDocs