geometry
Handles creation and management of geometries.
This module manages creation of geometries from csv file as well as openstreet data. Contains abstract as well as concrete classes for creating geometries.
Examples:
Get the buildings from chennai and prints one of the building geometry.
>>> from shift.geometry import BuildingsFromPlace
>>> g = BuildingsFromPlace("Chennai, India")
>>> geometries = g.get_geometries()
>>> print(geometries[0])
BuildingGeometry
Bases: Geometry
Implementation for Building geometry.
Source code in shift\geometry.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
area()
writable
property
float: Area property of a building
Source code in shift\geometry.py
111 112 113 114 |
|
BuildingsFromPlace
Bases: OpenStreetBuildingGeometries
Getting building geometries from a place address within bounding box.
Attributes:
Name | Type | Description |
---|---|---|
place |
str
|
Any place in string format e.g. chennai, india |
max_dist |
float
|
Distance in meter from the point to create a bounding box |
Source code in shift\geometry.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
__init__(place, max_dist=1000)
Instantiating the class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
place |
str
|
Any place in string format e.g. chennai, india |
required |
max_dist |
float
|
Distance in meter from the place to create a bounding box |
1000
|
Source code in shift\geometry.py
325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
get_gdf()
Refer to base class for details.
Source code in shift\geometry.py
339 340 341 342 343 |
|
BuildingsFromPoint
Bases: OpenStreetBuildingGeometries
Getting building geometries from single point within bounding box.
Attributes:
Name | Type | Description |
---|---|---|
point |
Sequence
|
Point in (latitude, longitude) format |
max_dist |
float
|
Distance in meter from the point to create a bounding box |
Source code in shift\geometry.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
__init__(point, max_dist=1000)
Instantiating the class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point |
Sequence
|
Point in (latitude, longitude) format |
required |
max_dist |
float
|
Distance in meter from the point to create a bounding box |
1000
|
Source code in shift\geometry.py
296 297 298 299 300 301 302 303 304 305 306 307 |
|
get_gdf()
Refer to base class for details.
Source code in shift\geometry.py
309 310 311 312 313 |
|
BuildingsFromPolygon
Bases: OpenStreetBuildingGeometries
Getting building geometries from a given polygon.
Attributes:
Name | Type | Description |
---|---|---|
polygon |
List[list]: Polygon to be used e.g. [[13.242134, 80.275948]] |
Source code in shift\geometry.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|
__init__(polygon)
Instantiating the class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
polygon |
List[list]
|
List[list]: Polygon to be used e.g. [[13.242134, 80.275948]] |
required |
Source code in shift\geometry.py
353 354 355 356 357 358 359 360 361 |
|
get_gdf()
Refer to base class for details.
Source code in shift\geometry.py
363 364 365 |
|
GeometriesFromCSV
Bases: ABC
Interface for getting geometries from CSV file
Attributes:
Name | Type | Description |
---|---|---|
csv_file |
str
|
Path to csv file |
df |
pd.DataFrame
|
dataframe holding the content of csv file |
Source code in shift\geometry.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
__init__(csv_file)
Method for instantiationg the class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
csv_file |
str
|
Path to valid csv file |
required |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If csv file is not found |
NotCompatibleFileError
|
If the file pssed is not csv |
Source code in shift\geometry.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
get_geometries()
abstractmethod
Child class must implement method to return list of geometries.
Source code in shift\geometry.py
185 186 187 188 |
|
validate()
abstractmethod
Child class must implement validate method.
Source code in shift\geometry.py
180 181 182 183 |
|
Geometry
Bases: ABC
Interface for Geometry object.
Source code in shift\geometry.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
latitude()
writable
property
float: Latitude property of a building
Source code in shift\geometry.py
74 75 76 77 |
|
longitude()
writable
property
float: Longitude property of a building
Source code in shift\geometry.py
86 87 88 89 |
|
OpenStreetBuildingGeometries
Bases: OpenStreetGeometries
Concrete implementations of open street building geometries
Source code in shift\geometry.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
get_geometries()
Refer to base class for details.
Source code in shift\geometry.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
OpenStreetGeometries
Bases: ABC
Interface for getting geometries from OpenStreet data.
Source code in shift\geometry.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
get_gdf()
abstractmethod
Method to return the geo dataframe containing all the buildings.
Returns:
Type | Description |
---|---|
pd.DataFrame
|
pd.DataFrame: Geo dataframe containing all the buildings. |
Source code in shift\geometry.py
224 225 226 227 228 229 230 231 |
|
get_geometries()
abstractmethod
Method to return all the geometry objects.
Returns:
Type | Description |
---|---|
List[Geometry]
|
List[Geometry]: list of all the building geometry objects. |
Source code in shift\geometry.py
233 234 235 236 237 238 239 240 |
|
SimpleLoadGeometriesFromCSV
Bases: GeometriesFromCSV
Concrete implementations for getting simple load geometries from CSV file.
Refer to the base class for more deatils on how to construct the object.
Source code in shift\geometry.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
get_geometries()
Method to get all the gepmetries from csv.
Source code in shift\geometry.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
validate()
Method to validate the content of csv file.
Source code in shift\geometry.py
216 217 218 |
|
SimpleLoadGeometry
Bases: Geometry
Implementation for simple load point geometry
Source code in shift\geometry.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
kw()
writable
property
float: Area property of a building
Source code in shift\geometry.py
133 134 135 136 |
|