Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %matplotlib
- # coding: utf-8
- #import geopandas as gpd
- import matplotlib.pyplot as plt
- from descartes import PolygonPatch
- from shapely.geometry import Point, LineString
- import requests
- code_postal = '92320'
- # Recupération du code Insee
- url_api ="https://geo.api.gouv.fr/communes?codePostal={}".format(code_postal)
- data_api = requests.get(url_api)
- json_api =data_api.json()
- commune = json_api[0]['code']
- nom_ville=json_api[0]['nom']
- pop=json_api[0]['population']
- print('Ville : {0}, Code insee {1}, {2} Habitants'.format(nom_ville,commune,pop))
- url_parcelles = 'https://cadastre.data.gouv.fr/bundler/cadastre-etalab/communes/{}/geojson/parcelles'.format(commune)
- data_parcelles = requests.get(url_parcelles)
- # In[ ]:
- surf_min =309 #surface minimum à chercher
- surf_max = 309 #surface max à chercher
- BLUE = '#6699cc'
- RUE = '#0099CC'
- f, ax = plt.subplots(1, figsize=(25,25 ))
- cpt=0
- for bcl in data_parcelles.json()['features']:
- poly=bcl['geometry']
- ax.add_patch(PolygonPatch(poly, fc=BLUE, ec=BLUE, alpha=0.7, zorder=0 ))
- try:
- if bcl['properties']['contenance'] in range(surf_min,surf_max+1):
- cpt+=1
- x,y=zip(*poly['coordinates'][0])
- center=(max(x)+min(x))/2., (max(y)+min(y))/2.
- lon=center[0]
- lat=center[1]
- plt.scatter(lon,lat,color='red',zorder=1)
- ax.annotate(cpt,(lon,lat),size=20)
- surf=bcl['properties']['contenance']
- url = 'http://maps.google.com/maps?z=15&t=k&q='+str(lat)+','+str(lon)
- print (cpt, url , surf )
- except:
- pass
- ax.axis('auto')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement