-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11e50e2
commit 594b2f9
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bars.json | ||
cafes.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Bars | ||
|
||
Verleende exploitatievergunningen horeca met terrasgrenzen en ontheffingen | ||
https://data.amsterdam.nl/data/datasets/GsY50tEkoJKCGw/verleende-exploitatievergunningen-horeca-met-terrasgrenzen-en-ontheffingen?term=Verleende+exploitatievergunningen+horeca+met+terrasgrenzen+en+ontheffingen | ||
|
||
https://api.data.amsterdam.nl/dcatd/datasets/GsY50tEkoJKCGw | ||
|
||
|
||
|
||
## Explore | ||
|
||
```bash | ||
curl 'https://api.data.amsterdam.nl/dcatd/datasets/GsY50tEkoJKCGw' > bars_metadata.json | ||
|
||
# Get the endpoint of the correct data endpoint: | ||
cat bars_metadata.json | jq '."dcat:distribution"[] | select( ."dct:title" == "Exploitatievergunningen")' | ||
|
||
# Download dataset from "wfs" type: | ||
curl 'https://api.data.amsterdam.nl/v1/wfs/horeca/?REQUEST=GetFeature&SERVICE=WFS&version=2.0.0&count=5000&typenames=exploitatievergunning&BBOX=4.58565,52.03560,5.31360,52.48769,urn:ogc:def:crs:EPSG::4326&outputformat=geojson&srsName=urn:ogc:def:crs:EPSG::4326' > bars.json | ||
|
||
# View location names | ||
jq '.features[].properties.zaaknaam' bars.json | ||
|
||
# All types of locations | ||
jq '.features[].properties.zaak_categorie' bars.json | sort -u | ||
|
||
# Locations of a specific type | ||
jq '.features[] | select(.properties.zaak_categorie == "Café") | .properties.zaaknaam' bars.json | ||
|
||
# Some "zaak_categorie" have sub-categories "zaak_specificatie" | ||
# Example: Cafe -> (Cafe, Eetcafe) | ||
jq '.features[] | select(.properties.zaak_categorie == "Onbekend") | .properties.zaak_specificatie' bars.json | ||
``` | ||
|
||
## Import | ||
|
||
```bash | ||
# Filter on Cafes | ||
jq '.features[] | select(.properties.zaak_categorie == "Café")' bars.json > cafes.json | ||
|
||
poetry run python render_template.py | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% for loc in locations %} | ||
INSERT INTO "locations" ("name", "coordinates", "published", "description", "osm_node_id", "google_place_id", "imageurl", "address_line") | ||
VALUES ( | ||
'{{ loc.properties.zaaknaam | replace("'", "''") }}', | ||
ST_FlipCoordinates(ST_GeomFromGeoJSON('{{ loc.geometry | tojson }}')), | ||
'1', | ||
'{{ loc.properties.zaak_specificatie }}', | ||
NULL, | ||
NULL, | ||
NULL, | ||
'{{ loc.properties.adres | replace("'", "''") }}' | ||
); | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"dct:title": "Verleende exploitatievergunningen horeca met terrasgrenzen en ontheffingen", "dct:description": "Naam, adres, categorie, datum, locatie en terrasgrenzen van verleende exploitatievergunningen voor Horeca. \n\nDe opgenomen\u00a0gegevens komen uit het Horeca Informatie Systeem van de gemeente Amsterdam. Hierin wordt informatie over horecazaken en vergunningen bijgehouden.\u00a0 Aan de hier getoonde informatie kunnen geen rechten worden ontleend. De daadwerkelijk afgegeven ontheffingen en vergunningen zijn geldend. U kunt deze opvragen bij de afdeling Vergunningen van het stadsdeel waar de vestiging zich bevind.", "ams:status": "beschikbaar", "dcat:distribution": [{"dct:title": "Weergave op de kaart", "dcat:accessURL": "https://www.amsterdam.nl/ondernemen/horeca/horeca-kaart/", "ams:purl": "https://api.data.amsterdam.nl/dcatd/datasets/GsY50tEkoJKCGw/purls/1HTNDkqQCILyQA", "ams:resourceType": "vis", "ams:distributionType": "web", "dct:modified": "2018-12-04", "dc:identifier": "1HTNDkqQCILyQA", "ams:classification": "public", "dcat:byteSize": 0, "foaf:isPrimaryTopicOf": {"dct:issued": "2016-10-11", "dct:modified": "2018-12-04"}, "dct:license": "cc-by", "@id": "_:d1"}, {"dct:title": "Exploitatievergunningen", "dcat:accessURL": "https://api.data.amsterdam.nl/v1/wfs/horeca/?REQUEST=GetFeature&SERVICE=WFS&version=2.0.0&count=5000&typenames=exploitatievergunning&BBOX=4.58565,52.03560,5.31360,52.48769,urn:ogc:def:crs:EPSG::4326&outputformat=geojson&srsName=urn:ogc:def:crs:EPSG::4326", "ams:purl": "https://api.data.amsterdam.nl/dcatd/datasets/GsY50tEkoJKCGw/purls/1", "ams:resourceType": "data", "ams:distributionType": "api", "ams:serviceType": "wfs", "dct:modified": "2020-06-30", "dc:identifier": "1", "ams:classification": "public", "dcat:byteSize": 0, "foaf:isPrimaryTopicOf": {"dct:issued": "2020-06-30", "dct:modified": "2020-06-30"}, "dct:license": "cc-by", "@id": "_:d2"}, {"dct:title": "Geometrie\u00ebn terrassen", "dcat:accessURL": "https://api.data.amsterdam.nl/v1/wfs/horeca/?REQUEST=GetFeature&SERVICE=WFS&version=2.0.0&count=5000&typenames=exploitatievergunning-terrasgeometrie&BBOX=4.58565,52.03560,5.31360,52.48769,urn:ogc:def:crs:EPSG::4326&outputformat=geojson&srsName=urn:ogc:def:crs:EPSG::4326", "ams:purl": "https://api.data.amsterdam.nl/dcatd/datasets/GsY50tEkoJKCGw/purls/2", "ams:resourceType": "data", "ams:distributionType": "api", "ams:serviceType": "wfs", "dct:modified": "2020-06-30", "dc:identifier": "2", "ams:classification": "public", "dcat:byteSize": 0, "foaf:isPrimaryTopicOf": {"dct:issued": "2020-06-30", "dct:modified": "2020-06-30"}, "dct:license": "cc-by", "@id": "_:d3"}, {"dct:title": "Exploitatievergunningen", "dcat:accessURL": "https://api.data.amsterdam.nl/v1/wfs/horeca/?REQUEST=GetFeature&SERVICE=WFS&version=2.0.0&count=5000&typenames=exploitatievergunning&outputformat=csv&srsName=urn:ogc:def:crs:EPSG::4326", "ams:purl": "https://api.data.amsterdam.nl/dcatd/datasets/GsY50tEkoJKCGw/purls/3", "ams:resourceType": "data", "ams:distributionType": "file", "dcat:mediaType": "text/csv", "dct:modified": "2020-06-30", "dc:identifier": "3", "ams:classification": "public", "dcat:byteSize": 0, "foaf:isPrimaryTopicOf": {"dct:issued": "2020-06-30", "dct:modified": "2020-06-30"}, "dct:license": "cc-by", "@id": "_:d4"}, {"dct:title": "Geometrie\u00ebn terrassen", "dcat:accessURL": "https://api.data.amsterdam.nl/v1/wfs/horeca/?REQUEST=GetFeature&SERVICE=WFS&version=2.0.0&count=5000&typenames=exploitatievergunning-terrasgeometrie&BBOX=4.58565,52.03560,5.31360,52.48769,urn:ogc:def:crs:EPSG::4326&outputformat=csv&srsName=urn:ogc:def:crs:EPSG::4326", "ams:purl": "https://api.data.amsterdam.nl/dcatd/datasets/GsY50tEkoJKCGw/purls/4", "ams:resourceType": "data", "ams:distributionType": "file", "dcat:mediaType": "text/csv", "dct:modified": "2020-06-30", "dc:identifier": "4", "ams:classification": "public", "dcat:byteSize": 0, "foaf:isPrimaryTopicOf": {"dct:issued": "2020-06-30", "dct:modified": "2020-06-30"}, "dct:license": "cc-by", "@id": "_:d5"}], "overheidds:doel": "...", "foaf:isPrimaryTopicOf": {"dct:issued": "2016-12-07", "dct:modified": "2019-01-21"}, "dct:accrualPeriodicity": "day", "dct:temporal": {}, "ams:temporalUnit": "days", "ams:spatialUnit": "specific", "dct:language": "lang1:nl", "ams:owner": "Gemeente Amsterdam", "dcat:contactPoint": {"vcard:fn": "horecavergunningen", "vcard:hasEmail": "[email protected]"}, "dct:publisher": {"foaf:name": "O. Morris", "foaf:mbox": "[email protected]"}, "dcat:theme": ["theme:bestuur", "theme:economie-en-toerisme", "theme:cultuur-en-recreatie"], "dcat:keyword": ["Horeca Informatie Systeem", "exploitatie", "horeca", "vergunningen", "terras", "terrascontour", "terrasgrenzen", "geluidsontheffing"], "ams:license": "cc-by", "dct:identifier": "GsY50tEkoJKCGw", "ams:sort_modified": "2020-06-30", "ams:modifiedby": "[email protected]", "@context": {"ams": "http://datacatalogus.amsterdam.nl/term/", "ckan": "https://ckan.org/terms/", "class": "ams:class#", "dc": "http://purl.org/dc/elements/1.1/", "dcat": "http://www.w3.org/ns/dcat#", "dct": "http://purl.org/dc/terms/", "foaf": "http://xmlns.com/foaf/0.1/", "lang1": "http://id.loc.gov/vocabulary/iso639-1/", "lang2": "http://id.loc.gov/vocabulary/iso639-2/", "org": "ams:org#", "overheid": "http://standaarden.overheid.nl/owms/terms/", "overheidds": "http://standaarden.overheid.nl/owms/terms/ds#", "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs": "http://www.w3.org/2000/01/rdf-schema#", "void": "http://rdfs.org/ns/void#", "skos": "http://www.w3.org/2004/02/skos/core#", "theme": "ams:theme#", "time": "http://www.w3.org/2006/time#", "vcard": "http://www.w3.org/2006/vcard/ns#", "ams:purl": {"@type": "@id"}, "dcat:dataset": {"@container": "@list"}, "dcat:distribution": {"@container": "@set"}, "dcat:keyword": {"@container": "@set"}, "dcat:landingpage": {"@type": "@id"}, "dcat:theme": {"@container": "@set", "@type": "@id"}, "dct:issued": {"@type": "xsd:date"}, "dct:language": {"@type": "@id"}, "dct:modified": {"@type": "xsd:date"}, "foaf:homepage": {"@type": "@id"}, "foaf:mbox": {"@type": "@id"}, "vcard:hasEmail": {"@type": "@id"}, "vcard:hasURL": {"@type": "@id"}, "vcard:hasLogo": {"@type": "@id"}, "ams-dcatd": "https://api.data.amsterdam.nl/dcatd/datasets/"}, "overheid:authority": "overheid:Amsterdam", "@id": "ams-dcatd:GsY50tEkoJKCGw"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from jinja2 import Environment, FileSystemLoader | ||
from pathlib import Path | ||
import json | ||
|
||
|
||
env = Environment( | ||
loader=FileSystemLoader("."), | ||
) | ||
|
||
|
||
def main(): | ||
template = env.get_template("insert-bars.sql.j2") | ||
data = json.loads(Path("cafes.json").read_text()) | ||
print(template.render(locations=data)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |