Last active
January 9, 2020 08:58
-
-
Save ThomasG77/cad711667942826edc70 to your computer and use it in GitHub Desktop.
Just one method to convert 2D to 3D geometry with shapely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from shapely.geometry import LineString | |
from shapely import wkt | |
line = LineString([(0, 0, 5), (1, 1, 5)]) | |
# memo for 3D | |
wkt3D = line.wkt | |
# 2D | |
wkt2D = line.to_wkt() | |
geometry2D = wkt.loads(wkt2D) | |
print geometry2D.wkt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think a better approach is to use
shapely.ops.transform
.This can also be used to convert other geometries. And the other way around, to remove the third coordinate: