[英]How to write a list of Polygons to a .shp file in Python
I have outmulti
being a list of 389 Polygon & Multipolygon objects in Python.我在
outmulti
中有一个包含 389 个多边形和多多边形对象的列表。 I want to write outmulti
to an shp file and then be able to actually see all the Polygons and Multipolygons in the space.我想将
outmulti
写入 shp 文件,然后能够实际看到空间中的所有多边形和多多边形。
I am stuck here.. How can I achieve that?我被困在这里..我怎样才能做到这一点?
Thanks in advance提前致谢
Convert your list to geopandas.GeoDataFrame
and save that.将您的列表转换为
geopandas.GeoDataFrame
并保存。 If you know the projection, you should pass it to GeoDataFrame as well.如果你知道投影,你也应该将它传递给 GeoDataFrame。
import geopandas
gdf = geopandas.GeoDataFrame(geometry=outmulti)
# gdf = geopandas.GeoDataFrame(geometry=outmulti, crs="EPSG:4326") # if you have coordinates in degrees
gdf.to_file("my_file.shp")
To see your geometries in space, you can plot them with geopandas.要查看您在太空中的几何形状,您可以使用 geopandas plot 它们。
gdf.plot()
Check the documentation for details.检查文档以获取详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.