Skip to content

Explorer un provider avec l'API carto (en version beta sur les flux du géoportail) #57

Description

@tgrandje

Pas réussi à attaquer directement les flux WFS (retour systématique d'un "MissingParameter" non précisé).

Ne fonctionne pas :

from owslib.wfs import WebFeatureService
url = "https://wxs.ign.fr/geoportail/wfs"
wfs = WebFeatureService(url=url, version='2.0.0')
cog_files = [
    x for x in wfs.contents
    if 'cog' in x.lower()
    and 'carto' in x.lower()
    and 'latest' in x.lower()
    ]
print(wfs.getfeature(cog_files[-1]).read())

En revanche, l'appel via l'API carto en version beta fonctionne ; le débit semble beaucoup plus rapide que sur le site de l'IGN (mais les md5 ne sont par contre pas fournis, il faudra les calculer à réception) :

from owslib.wfs import WebFeatureService
import geopandas as gpd
import requests

url = "https://wxs.ign.fr/geoportail/wfs"
wfs = WebFeatureService(url=url, version='2.0.0')
cog_files = [
    x for x in wfs.contents
    if 'cog' in x.lower()
    and 'carto' in x.lower()
    and 'latest' in x.lower()
    ]
print(cog_files)
file = cog_files[-1]
bbox_world = """{"type":"Polygon", "coordinates":[[[-180,-90],[-180,90],[180,90],[180,-90],[-180,-90]]]}"""
r = requests.get(
    'https://apicarto.ign.fr/api/wfs-geoportail/search',
    params={"source":file, "geom":bbox_world}
    )
gdf = gpd.GeoDataFrame.from_features(r.json())
gdf.plot()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions