Import error from shapely package



I imported shapely package and I am calculating intersection area of multipolygons, but I got this error,

ImportError: No module named shapely.geometry.geo

is there any issue with shapely package? how to solve this issue?


@Ravindranath_Edlapat Can you get us the complete code which is your trying?


@annapurna this is the code I am running,

from shapely import *
from shapely.geometry import asShape
from shapely.ops import unary_union

def poly_coord(line):
parsed_line = line.replace(’"’,’’).split(‘POLYGON ‘)[1].replace(’(’,’’).replace(’)’,’’).split(’ ')
float_point = [float(parsed_line[i]) for i in range(0,len(parsed_line))]
coordinates = [[[float_point[i:i+2] for i in range(0,len(float_point),2)]]]
return coordinates
def to_shape(multi_polygon):
def to_multi_polygon_json(multi_polygon_json):
ps = []
for p in multi_polygon_json:
ls = []
for l in p:
cs = []
for c in l:
ds = []
for d in c:
cs.append((ds[0], ds[1]))
return {‘type’: ‘MultiPolygon’, ‘coordinates’: ps}
return asShape(to_multi_polygon_json(multi_polygon))

def intersection_area(multi_polygon_a, multi_polygon_b):
a = to_shape(multi_polygon_a)
b = to_shape(multi_polygon_b)
return a.intersection(b).area

line = sc.textFile(’/user/edraviitbig/myrepo/melb_urban_forest_2016.txt’)

uf =

sa2 =’/user/edraviitbig/myrepo’)
sa2c = sa2.drop(’_corrupt_record’).dropna()
sa2sub =,sa2c.geometry)
sa2subRDD = s: (s[0],s[1].coordinates))

subCartUf = sa2subRDD.cartesian(uf)
suburbGreen = s: (s[0][0], intersection_area(s[0][1],s[1])))

here I am getting the error ,
ImportError: No module named shapely.geometry.geo


You have given variable as SubCartUf instead of subCartUf.


@annapurna I am getting the same error with the variable subCartUf.