py4design.pycitygml package¶
Submodules¶
Module contents¶
-
class
py4design.pycitygml.
Writer
¶ Bases:
object
lxml.etree Element object that contains the CityGML information. Currently all methods only work with lod1 CityGML models.
…
Attributes
citymodel_node ( lxml.etree Element) The Element class that contains all the CityGML information. -
create_cityobjectmember
()¶ This function creates a cityObjectMember.
-
add_landuse
(lod, name, geometry_list, function=None, generic_attrib_dict=None)¶ This function adds a landuse object into the CityGML model. Currently, only works for lod1 landuse.
Parameters: lod : str
The level of detail of the geometry of the landuse. The string should be in this form: “lod1”.
name : str
The name of the landuse.
geometry_list : list of SurfaceMember
The geometry of the landuse.
function : str, optional
The function of the landuse in gml code, e.g. for residential specify “1010”, Default = None. Refer to CityGML documentation for more information. https://www.citygml.org/
generic_attrib_dict : dictionary, optional
Extra attributes to be appended to the object, Default = None. The dictionary must have a string key which will be the name of the generic attributes, and either an int, float or str value.
-
add_transportation
(trpt_type, lod, name, geometry_list, rd_class=None, function=None, generic_attrib_dict=None)¶ This function adds a transportation object into the CityGML model. Transportation object includes road, railway, track and square. Currently only works for lod0 transportation network.
Parameters: trpt_type : str
The transportation type. The options are: “Road”, “Railway”, “Track”, “Square”.
lod : str
The level of detail of the geometry of the transportation. The string should be in this form: “lod0”.
name : str
The name of the transportation object.
geometry_list : list of Linestring
The geometry of the landuse.
rd_class : str, optional
The class of the transportation gml code, e.g. for road specify “1000”, Default = None. Refer to CityGML documentation for more information. https://www.citygml.org/
function : str, optional
The function of the transportation gml code, e.g. for road specify “1000”, Default = None. Refer to CityGML documentation for more information. https://www.citygml.org/
generic_attrib_dict : dictionary, optional
Extra attributes to be appended to the object, Default = None. The dictionary must have a string key which will be the name of the generic attributes, and either an int, float or str value.
-
add_building
(lod, name, geometry_list, bldg_class=None, function=None, usage=None, yr_constr=None, rooftype=None, height=None, stry_abv_grd=None, stry_blw_grd=None, generic_attrib_dict=None)¶ This function adds a building object into the CityGML model. Currently, only works for lod1 building.
Parameters: lod : str
The level of detail of the geometry of the building. The string should be in this form: “lod1”.
name : str
The name of the building.
geometry_list : list of SurfaceMember
The geometry of the building.
bldg_class : str, optional
The building class of the building in gml code e.g. for habitation specify “1000”, Default = None. Refer to CityGML documentation for more information. https://www.citygml.org/
function : str, optional
The function of the building in gml code e.g. for residential specify “1000”, Default = None. Refer to CityGML documentation for more information. https://www.citygml.org/
usage : str, optional
The usage of the building in gml code e.g. for residential specify “1000”, Default = None. Refer to CityGML documentation for more information. https://www.citygml.org/
yr_constr : str, optional
The year the building is constructed e.g. “2017”, Default = None.
rooftype : str, optional
The rooftype of the building in gml code e.g. for flat roof specify “1000”, Default = None. Refer to CityGML documentation for more information. https://www.citygml.org/
height : str, optional
The height of the building, e.g. “48”, Default = None.
stry_abv_grd : str, optional
The number of storey of the building above ground, e.g. “12”, Default = None.
stry_blw_grd : str, optional
The number of storey of the building below ground, e.g. “2”, Default = None.
generic_attrib_dict : dictionary, optional
Extra attributes to be appended to the object, Default = None. The dictionary must have a string key which will be the name of the generic attributes, and either an int, float or str value.
-
add_cityfurniture
(lod, name, geometry_list, furn_class=None, function=None, generic_attrib_dict=None)¶ This function adds a city furniture object into the CityGML model. Currently, only works for lod1.
Parameters: lod : str
The level of detail of the geometry of the furniture. The string should be in this form: “lod1”.
name : str
The name of the furniture.
geometry_list : list of SurfaceMember
The geometry of the furniture.
furn_class : str, optional
The furniture class of the city furniture in gml code, for traffic specify “1000”, Default = None. Refer to CityGML documentation for more information. https://www.citygml.org/
function : str, optional
The function of the city furniture in gml code, for bus stop specify “1110”,Default = None. Refer to CityGML documentation for more information. https://www.citygml.org/
generic_attrib_dict : dictionary, optional
Extra attributes to be appended to the object, Default = None. The dictionary must have a string key which will be the name of the generic attributes, and either an int, float or str value.
-
add_tin_relief
(lod, name, geometry_list)¶ This function adds a TIN relief object into the CityGML model. Currently, only works for lod1.
Parameters: lod : str
The level of detail of the geometry of the tin relief. The string should be in this form: “lod1”.
name : str
The name of the relief feature.
geometry_list : list of Triangle
The geometry of the relief.
-
add_bounded_by
(epsg, lower_bound, upper_bound)¶ This function adds a bounded by object into the CityGML model.
Parameters: epsg : str
The epsg of the coordinate system.
lower_bound : tuple of floats
A tuple of floats that is specifying the xyz coordinate of the lower bound.
upper_bound : tuple of floats
A tuple of floats that is specifying the xyz coordinate of the upper bound.
-
write2string
()¶ This function prints all the information into a string.
-
write
(filepath)¶ This function writes all the information into a CityGML file.
Parameters: filepath : str
The file path of the CityGML file.
-
-
class
py4design.pycitygml.
Reader
¶ Bases:
object
Reads a CityGML file and stores it in a lxml.etree Element object that contains the CityGML information.
…
Attributes
citymodel_node ( lxml.etree Element) The Element class that contains all the CityGML information. cityobjectmembers (list of lxml.etree Element) A list of Element class of all the cityobjectmembers in the CityGML file. namespaces (dictionary of XMLNamespaces from write_gml module) A dictionary of XMLNamespaces. -
load_filepath
(filepath)¶ This function loads the CityGML file and all the information into the citymodelnode and populate the cityobjectmembers.
Parameters: filepath : str
The file path of the CityGML file.
-
load_citymodel_node
(citymodel_node)¶ This function loads a citymodel_node and populate the cityobjectmembers.
Parameters: filepath : str
The file path of the CityGML file.
Raises: Exception
when a CityGML file has already been loaded.
-
get_buildings
()¶ This function gets all the buildings from the loaded CityGML file.
Returns: buildings : list of lxml Elements
A list of lxml Elements buildings.
-
get_relief_feature
()¶ This function gets the relief feature cityobject.
Returns: relief features: list of lxml Elements
List of relief feature lxml Element.
-
get_landuses
()¶ This function gets the landuse cityobject.
Returns: landuses : list of lxml Elements
List of landuses lxml Element.
-
get_roads
()¶ This function gets the roads cityobject.
Returns: roads : list of lxml Elements
List of roads lxml Element.
-
get_railways
()¶ This function gets the railway cityobject.
Returns: railways : list of lxml Elements
List of railway lxml Elements.
-
get_non_xtype_cityobject
(xtype)¶ This function find all cityobject that is not of xtype.
Parameters: xtype : str
A cityobject type, e.g. “bldg:Building”
Returns: non-xtype cityobject : list of lxml Elements
A list of lxml Elements non-xtype cityobjects.
-
get_building_height
(lxmlbuilding)¶ This function gets the height of the building.
Parameters: lxmlbuilding : lxml Element
A lxml building object.
Returns: building height : float
The building height, if attribute is not available return None.
-
get_building_storey
(lxmlbuilding)¶ This function gets the number of building storey above ground of the building.
Parameters: lxmlbuilding : lxml Element
A lxml building object.
Returns: building storey above ground : int
The building storey above ground, if attribute is not available return None.
-
get_building_function
(lxmlbuilding)¶ This function gets the function of the building.
Parameters: lxmlbuilding : lxml Element
A lxml building object.
Returns: building function code : str
The building function in gml code, if attribute is not available return None.
-
get_building_usage
(lxmlbuilding)¶ This function gets the function of the building.
Parameters: lxmlbuilding : lxml Element
A lxml building object.
Returns: building usage code : str
The building usage in gml code, if attribute is not available return None.
-
get_building_class
(lxmlbuilding)¶ This function gets the class of the building.
Parameters: lxmlbuilding : lxml Element
A lxml building object.
Returns: building class code : str
The building class in gml code, if attribute is not available return None.
-
get_building_yr_constr
(lxmlbuilding)¶ This function gets year of construction of the building.
Parameters: lxmlbuilding : lxml Element
A lxml building object.
Returns: building year of construction : str
The building year of construction, if attribute is not available return None.
-
get_building_rooftype
(lxmlbuilding)¶ This function gets year of construction of the building.
Parameters: lxmlbuilding : lxml Element
A lxml building object.
Returns: building rooftype : str
The building rooftype in gml code, if attribute is not available return None.
-
get_building_epsg
(lxmlbuilding)¶ This function gets the coordinate system epsg of the building.
Parameters: lxmlbuilding : lxml Element
A lxml building object.
Returns: building epsg : str
The building epsg, if attribute is not available return None.
-
get_building_storey_blw_grd
(lxmlbuilding)¶ This function gets the number of building storey below ground of the building.
Parameters: lxmlbuilding : lxml Element
A lxml building object.
Returns: building storey below ground : int
The building storey below ground, if attribute is not available return None.
-
get_generic_attribs
(cityobject)¶ This function gets the generic attribute of the cityobject.
Parameters: cityobject : lxml Element
A lxml cityobject.
Returns: dictionary generic attributes : dictionary
The dictionary have a string key which will be the name of the generic attributes, and either an int, float or str value.
-
get_landuse_name
(lxmllanduse)¶ This function gets the name of the landuse.
Parameters: lxmllanduse : lxml Element
A lxml landuse object.
Returns: landuse name : str
The name of the landuse.
-
get_landuse_function
(lxmllanduse)¶ This function gets the function of the landuse.
Parameters: lxmllanduse : lxml Element
A lxml landuse object.
Returns: landuse function : str
The function of the landuse.
-
get_bus_stops
()¶ This function gets the busstop cityobject.
Returns: bus stops : list of lxml Elements
List of bus stops lxml Element.
-
get_epsg
(cityobject)¶ This function gets the coordinate system epsg of the cityobject.
Parameters: cityobject : lxml Element
A lxml cityobject.
Returns: epsg : str
The cityobject epsg, if attribute is not available return None.
-
get_gml_id
(cityobject)¶ This function gets the id of the cityobject.
Parameters: cityobject : lxml Element
A lxml cityobject.
Returns: id : str
The cityobject id, if attribute is not available return None.
-
get_triangles
(cityobject)¶ This function gets the triangles geometry of the cityobject.
Parameters: cityobject : lxml Element
A lxml cityobject.
Returns: triangles : list of lxml triangles
List of lxml triangles.
-
get_polygons
(cityobject)¶ This function gets the polygon geometry of the cityobject.
Parameters: cityobject : lxml Element
A lxml cityobject.
Returns: polygons : list of lxml polygons
List of lxml polygons.
-
get_polygon_pt_list
(lxmlpolygon)¶ This function gets the list of points that defines the polygon.
Parameters: lxmlpolygon : lxml Element
A lxml polygon object.
Returns: list of polygon points : list of polygon point lxml Elements
The list of polygon point lxml elements. Each element is a polygon.
-
get_polygon_pt_list_2_pyptlist
(lxmlpolygon_pt_list)¶ This function gets the list of points that defines the polygon.
Parameters: lxmlpolygon_pt_list : list of lxml Elements
A list of lxml polygon point object.
Returns: list of points : pyptlist
A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]
-
polygon_2_pyptlist
(lxmlpolygon)¶ This function gets the list of points that defines the polygon.
Parameters: lxmlpolygon : list of lxml Elements
A list of lxml polygon object.
Returns: list of points : pyptlist
A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]
-
get_pypolygon_list
(cityobject)¶ This function gets a 2d list of points that defines the polygon. Pypolygon_list is a 2d list of tuples. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z). A pypolygon is a list of pypt that forms a polygon e.g. [(x1,y1,z1), (x2,y2,z2), …]. A pypolygon_list is a 2d list of tuples e.g. [[(x11,y11,z11), (x12,y12,z12), …], [(x21,y21,z21), (x22,y22,z22), …], …]
Parameters: cityobject : lxml Elements
A cityobject lxml Element.
Returns: 2d list of points : pypolygon_list
A 2d list that defines a list of polygons.
-
get_pytriangle_list
(cityobject)¶ This function gets a 2d list of points that defines the triangle. Pytriangle_list is a 2d list of tuples. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z). A pytriangle is a list of pypt that forms a polygon e.g. [(x1,y1,z1), (x2,y2,z2), …]. A pytriangle_list is a 2d list of tuples e.g. [[(x11,y11,z11), (x12,y12,z12), …], [(x21,y21,z21), (x22,y22,z22), …], …]
Parameters: cityobject : lxml Elements
A cityobject lxml Element.
Returns: 2d list of points : pytriangle_list
A 2d list that defines a list of triangles.
-
get_linestring
(cityobject)¶ This function gets the linestring (polyline) geometry of the cityobject. Currently, this method only works with lod0Network
Parameters: cityobject : lxml Element
A lxml cityobject.
Returns: polylines : list of lxml polylines
List of lxml polylines.
-
get_pylinestring_list
(cityobject)¶ This function gets a 2d list of points that defines the polylines. Pypolyline_list is a 2d list of tuples. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z). A pypolyline is a list of pypt that forms a polyline e.g. [(x1,y1,z1), (x2,y2,z2), …]. A pypolyline_list is a 2d list of tuples e.g. [[(x11,y11,z11), (x12,y12,z12), …], [(x21,y21,z21), (x22,y22,z22), …], …]
Parameters: cityobject : lxml Elements
A cityobject lxml Element.
Returns: 2d list of points : pypolyline_list
A 2d list that defines a list of polylines.
-
-
class
py4design.pycitygml.
SurfaceMember
(pyptlist)¶ Bases:
object
Writes a surface member object instance.
Parameters: pyptlist : list of tuples of floats
List of points to be written. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]
Attributes
pos_list ( pyptlist) List of points to be written. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …] -
construct
()¶ This function writes a GML surface member.
Returns: surface member : lxml Element
lxml surface member element.
-
-
class
py4design.pycitygml.
Triangle
(pyptlist)¶ Bases:
object
Writes a triangle object instance.
Parameters: pyptlist : list of tuples of floats
List of points to be written. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]
Attributes
pos_list ( pyptlist) List of points to be written. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …] -
construct
()¶ This function writes a GML triangle.
Returns: triangle : lxml Element
lxml triangle element.
-
-
class
py4design.pycitygml.
LineString
(pyptlist)¶ Bases:
object
Writes a linestring object instance.
Parameters: pyptlist : list of tuples of floats
List of points to be written. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]
Attributes
pos_list ( pyptlist) List of points to be written. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …] -
construct
()¶ This function writes a GML linestring.
Returns: linestring : lxml Element
lxml linestring element.
-
-
class
py4design.pycitygml.
Point
(pypt)¶ Bases:
object
Writes a point object instance.
Parameters: pypt : tuple of floats
A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z).
Attributes
pos_list ( pypt) A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z). -
construct
()¶ This function writes a GML point.
Returns: point : lxml Element
lxml point element.
-