从geojson多面体创建一个要素shapefile

时间:2017-05-02 23:36:21

标签: python-3.x geojson shapely.geometry

我正在尝试使用geoserver中的geojson文件创建shapefile,但在迭代Multipolygon功能以创建union shapefile时仍然会出错。谁能发现我哪里错了?

我的错误是:

  

ValueError:LinearRing必须至少有3个坐标元组

import geoserver_filtered as gs
import fiona, imaplib, geopy, pygeoj, geojson, gdal
from fiona.crs import from_epsg
from shapely.geometry import mapping, Polygon
from shapely.geometry import collection
from shapely.geometry import *
from shapely.ops import cascaded_union
import json



PARAMS_1 = {
"host": "mf2.dit.ie:8080",
"layer": "cso:ctygeom",
"srs_code": 29902,
"properties": ["countyname", ],
"geom_field": "geom",
"filter_property": "county",
"filter_values": ["05", "15", "03"]
}



#get variables
polygon_geojson = gs.PARAMS_1
f = gs.main()

for feature in f['features']:
    polygons = Polygon(['geometry'])

def make_union():
    nwpoly = polygon_geojson
    pol_list =[]

for feature in nwpoly['features']:
    polygons = shape(feature['geometry'])
    pol_list.append(polygons)

merged_shapes = cascaded_union(pol_list)
return merged_shapes

def mk_union_shp():
   union_shp = make_union()

try:
    schema = {'geometry': 'MultiPolygon', 'properties': {'name': 'str'}}
    with fiona.collection("union.shp", mode="w", driver="ESRI Shapefile", schema=schema, crs=from_epsg(4326)) as output:
        output.write({'properties': {'name': 'union_shp'}, 'geometry': mapping(union_shp)})

except:
    None

0 个答案:

没有答案