I'm new to GIS. Trying to use Finnish population data on 1km tiles available here: http://www.stat.fi/org/avoindata/paikkatietoaineistot_en.html
The WFS service is here: http://geo.stat.fi/geoserver/vaestoruutu/wfs
I'm using owslib to access the service:
from owslib.wfs import WebFeatureService
url = 'http://geo.stat.fi/geoserver/tilastointialueet/wfs'
wfs20 = WebFeatureService(url=url, version='2.0.0')
response = wfs20.getfeature(typename='tilastointialueet:hila1km')
First of all this response is huge, but I don't know how to ask for a smaller response. I don't understand how to get this response to a geopandas dataframe. I've tried:
out = open('data.gml', 'wb')
out.write(bytes(response.read(), 'UTF-8'))
out.close()
import geopandas
tiles = geopandas.read_file('data.gml')
but get the error CPLE_OpenFailedError: b'Unable to open EPSG support file gcs.csv. Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.'
I think that the correct EPSG should be 3067, but I don't know how to specify this when reading the file.
How to get this data to a geopandas dataframe?
Best Answer
UPDATE: Geopandas 0.4.0, allows to read data from URL directly. Thanks @SamTux for pointing it out!
OWSLib is good for reading the details and capabilities of specific WFS. For reading the data, I would use
request
module to first parse the URL with parameters, and then you can read the data directly from that URL usinggpd.read_file()
.Read WFS capabilities and metadata:
Read the data into GeoDataFrame: