[PYTHON] shapely svg output

Oh, isn't shapely popular? whatever

It is a sample from geojson to screen output with shapely.

Normally I would do it with matplotlib, but since I have svg, I will do this This is the code I wrote because I wanted to use it. What is it all about? It is supposed to be used with jupyter notebook.

There is also a function called .svg (), but this one doesn't work very well Is it because of chrome?

Is it possible to make it simpler by using leaflet or something? Well, after this display, I want to use intersection to find the intersection of lines, so I have to be shapely, but this Is there only an interface of \ _repr_svg \ _ ()? st.replace is overkill, but it can't be helped. Is it faster to play with the sauce?

tokyo.py


from shapely.geometry import *
import simplejson
from IPython.display import HTML

f=open('tokyo.geojson')
jsn=simplejson.load(f)
s=[]
for i in jsn['features']:
    if(i['properties']['area_en']=='Tokubu'):
        s.append(shape(i['geometry']))

sm=MultiPolygon(s)
st=sm._repr_svg_()
st=st.replace('width="100.0"','width="300.0"')
st=st.replace('height="100.0"','height="300.0"')
st=st.replace('stroke-width="0.0076922352"','stroke-width="0.0008922352"')
#st
HTML(st)

Recommended Posts

shapely svg output
Output conditions
Output beginner