Get Boundary
Get Boundary¶
Get the boundary of an object by: obj.Boundary()
In [1]:
Copied!
import geokit.core.srs
import geokit.core.geom
import matplotlib.pyplot as plt
import geokit.core.srs
import geokit.core.geom
import matplotlib.pyplot as plt
In [2]:
Copied!
# Make a line
aachen_centered_srs = geokit.core.srs.centeredLAEA(6.083, 50.775)
house_polygon = geokit.core.geom.polygon(
[
(0, 0),
(40000, 0),
(20000, 20000),
(40000, 40000),
(0, 40000),
(0, 0),
],
srs=4326,
)
print(type(house_polygon))
print(house_polygon.GetGeometryName())
# Make a line
aachen_centered_srs = geokit.core.srs.centeredLAEA(6.083, 50.775)
house_polygon = geokit.core.geom.polygon(
[
(0, 0),
(40000, 0),
(20000, 20000),
(40000, 40000),
(0, 40000),
(0, 0),
],
srs=4326,
)
print(type(house_polygon))
print(house_polygon.GetGeometryName())
<class 'osgeo.ogr.Geometry'> POLYGON
In [3]:
Copied!
# Get a boundary
boundary_polygon = house_polygon.Boundary()
print(type(boundary_polygon))
print(boundary_polygon.GetGeometryName())
# Get a boundary
boundary_polygon = house_polygon.Boundary()
print(type(boundary_polygon))
print(boundary_polygon.GetGeometryName())
<class 'osgeo.ogr.Geometry'> LINESTRING
In [4]:
Copied!
fig, axs = plt.subplots(ncols=2, nrows=1, figsize=(12, 6))
ax_handle = geokit.core.geom.drawGeoms(house_polygon, figsize=(6, 6), color="red", ax=axs[0])
ax_handle = geokit.core.geom.drawGeoms(
boundary_polygon,
figsize=(6, 6),
ax=axs[1],
color="black",
)
fig, axs = plt.subplots(ncols=2, nrows=1, figsize=(12, 6))
ax_handle = geokit.core.geom.drawGeoms(house_polygon, figsize=(6, 6), color="red", ax=axs[0])
ax_handle = geokit.core.geom.drawGeoms(
boundary_polygon,
figsize=(6, 6),
ax=axs[1],
color="black",
)