Neo4j Exercise 2. Spatial Procedures

Similar documents
Highly Migratory Species Essential Fish Habitat (EFH) Overlay February 27, 2015

Uninformed search methods II.

CENG 466 Artificial Intelligence. Lecture 4 Solving Problems by Searching (II)

GIS Based Non-Signalized Intersection Data Inventory Tool To Improve Traffic Safety

GEOG2113: Geographical Information Systems Week 7 Mapping Hazards & Threats Practical Task

Walking up Scenic Hills: Towards a GIS Based Typology of Crowd Sourced Walking Routes

Validation of 12.5 km Resolution Coastal Winds. Barry Vanhoff, COAS/OSU Funding by NASA/NOAA

2.2 TRANSIT VISION 2040 FROM VISION TO ACTION. Emphasize transit priority solutions STRATEGIC DIRECTION

Spatial/Seasonal overlap between the midwater trawl herring fishery and predator focused user groups

Vision Zero High Injury Network Methodology

Canadian Exploratory Olympics Sites Lesson Plan

Artificial Intelligence. Uninformed Search Strategies

Uninformed search strategies

Supplementary Material for Bayes Merging of Multiple Vocabularies for Scalable Image Retrieval

CS 4649/7649 Robot Intelligence: Planning

Uninformed search methods II.

ANALYSIS OF RURAL CURVE NEGOTIATION USING NATURALISTIC DRIVING DATA Nicole Oneyear and Shauna Hallmark

Accessibility and Cost Surfaces in the Boundary Waters Canoe Area, Minnesota

Pedestrian Dynamics: Models of Pedestrian Behaviour

Exploring the NFL. Introduction. Data. Analysis. Overview. Alison Smith <alison dot smith dot m at gmail dot com>

The Operations Research Challenge 2018: Part I

Estimating a Toronto Pedestrian Route Choice Model using Smartphone GPS Data. Gregory Lue

Lesson 18: There Is Only One Line Passing Through a Given Point with a Given Slope

Pore-Air Entrapment during Infiltration

Safety Assessment of Installing Traffic Signals at High-Speed Expressway Intersections

Canada s Natural Systems. Canadian Geography 1202

Princess Nora University Faculty of Computer & Information Systems ARTIFICIAL INTELLIGENCE (CS 370D) Computer Science Department

Look Twice! Inventorying Pavement Markings for the City of Austin. Our story of how we accomplished data inventory of our city crosswalks.

CSE 3401: Intro to AI & LP Uninformed Search II

Using SQL in MS Access

Problem Solving Agents

How networks are shaping Tshwane Tools for urban network analysis Part II

Introduction to Sugar Access. Sugar Access - Measuring Accessibility (Robert Kohler, Citilabs) Slide 1 of 21

Conflating a Traffic Model Network With a Road Inventory. David Knudsen

Decision Trees. an Introduction

CENTERLINES DOCUMENTATION

Company Surge TM for. Installation Guide v4.0 January

A Shallow Dive into Deep Sea Data Sarah Solie and Arielle Fogel 7/18/2018

Transposition Table, History Heuristic, and other Search Enhancements

Rogue Valley Metropolitan Planning Organization. Transportation Safety Planning Project. Final Report

Trial of a process to estimate depth of cover on buried pipelines

Influencing Factors on Conflicts of Turning Vehicles and Pedestrians at Intersections

Session 2: Introduction to Multilevel Modeling Using SPSS

SIDRA INTERSECTION 6.1 UPDATE HISTORY

Multilane Roundabouts

AN AUTONOMOUS DRIVER MODEL FOR THE OVERTAKING MANEUVER FOR USE IN MICROSCOPIC TRAFFIC SIMULATION

Uninformed search methods

Predicting the development of the NBA playoffs. How much the regular season tells us about the playoff results.

Canada s Capital Region Delegation to the Velo-City Global 2010 Conference

CSE 3402: Intro to Artificial Intelligence Uninformed Search II

Mining and Agricultural Productivity

TECHNICAL NOTE HOW TO USE LOOPERS. Kalipso_TechDocs_Loopers. Revision: 1.0. Kalipso version: Date: 16/02/2017.

BUS RAPID TRANSIT. A Canadian Perspective. McCormick Rankin International. John Bonsall P.Eng

Travel Time Survey Pilot Study

Lossless Comparison of Nested Software Decompositions

METHODS PAPER: Downstream Bathymetry and BioBase Analyses of Substrate and Macrophytes

Solving Problems by Searching chap3 1. Problem-Solving Agents

GAZIFÈRE INC. Prime Rate Forecasting Process 2015 Rate Case

Couples, Relations and Functions

7 th Annual Golf Tournament & Luncheon SPONSORSHIP OPPORTUNITIES 2018

We release Mascot Server 2.6 at the end of last year. There have been a number of changes and improvements in the search engine and reports.

Expanding Square Search Pattern HEY! I M OVER HERE!!!

Flyweight Pattern. Flyweight: Intent. Use sharing to support large numbers of fine-grained objects efficiently. CSIE Department, NTUT Chien-Hung Liu

Observation-Based Lane-Vehicle Assignment Hierarchy

Alberta Centre for Active Living ALBERTA SURVEY ON PHYSICAL ACTIVITY EXECUTIVE SUMMARY. Supported by:

RELATIONSHIP BETWEEN CONGESTION AND TRAFFIC ACCIDENTS ON EXPRESSWAYS AN INVESTIGATION WITH BAYESIAN BELIEF NETWORKS

Heap Sort. Lecture 35. Robb T. Koether. Hampden-Sydney College. Mon, Apr 25, 2016

Uninformed Search (Ch )

Combined impacts of configurational and compositional properties of street network on vehicular flow

Alternative Impedances for Shortest Path Network Analysis for Cycling

GN21 Frequently Asked Questions For Golfers

Marine Mammal Scientific Support Research Programme MMSS/001/11

Geospatial Analysis of High-Crash Intersections and Rural Roads using Naturalistic Driving Data

SAN FRANCISCO MUNICIPAL TRANSPORTATION AGENCY BOARD OF DIRECTORS. RESOLUTION No

CITI BIKE S NETWORK, ACCESSIBILITY AND PROSPECTS FOR EXPANSION. Is New York City s Premier Bike Sharing Program Accesssible to All?

POTHOLES IN EDMONTON. Updated: April 4, 2013

Spatial and Temporal Patterns of Pedestrian Crashes Along The Urbanization Gradient

Real World Search Problems. CS 331: Artificial Intelligence Uninformed Search. Simpler Search Problems. Example: Oregon. Search Problem Formulation

Chapter 12 Practice Test

Exercise 11: Solution - Decision tree

Introduction. AI and Searching. Simple Example. Simple Example. Now a Bit Harder. From Hammersmith to King s Cross

Redis Graph. A graph database built on top of redis

SIDDHARTH INSTITUTE OF ENGINEERING & TECHNOLOGY :: PUTTUR (AUTONOMOUS) Siddharth Nagar, Narayanavanam Road QUESTION BANK (DESCRIPTIVE)

Package macleish. January 3, 2018

TO.FLOW. Author: Giuseppe Lassandro. Final Project for TechniCity Course Coursera. by Dr. Jennifer Evans-Cowley, Thomas W.

Study Guide and Intervention

A Pyramid of Crunchkins

How to Use DeVry Library Databases for NoodleTools

Statewide Cycloplan: Bicycle Planning Tool & Participatory GIS

Uninformed search methods

Trans Canada Trail Véloroute Voyageur Cycling Route WAYFINDING SIGNAGE PLAN for Low to Moderate Volume Highways

Piecewise Functions. Updated: 05/15/10

A Framework For Integrating Pedestrians into Travel Demand Models

Web Based Bicycle Trip Planning for Broward County, Florida

Northwestern Ontario Sports Hall of Fame Sports Heritage Education Program. Lesson Ideas for Grades 7-8

Operational Ranking of Intersections: A Novel Prioritization Methodology

Pedestrian Behaviour Modelling

RE: 100 VARLEY LANE TRANSPORTATION OVERVIEW

Combination Analysis Tutorial

Addendum to the LeagueOne User Guide for Club Registrars

Transcription:

GGE5402/6405: Geographic Databases Fall 2016 Neo4j Exercise 2 CREATE A GRAPH DB FOR CANADIAN CITIES Emmanuel Stefanakis estef@unb.ca Spatial Procedures CALL spatial.procedures 1

CALL spatial.procedures Spatial Procedures Spatial Procedures CALL spatial.procedures 2

Dataset (Canadian Cities) Dataset (Canadian Cities) 3

// Create a point layer (cities) CALL spatial.addpointlayer('cities'); 4

// Import cities from shapefile CALL spatial.importshapefiletolayer('cities', 'C:/Users/estef/Documents/GGE6405/2016/data/Canada_Cities.shp') 5

6

// Retrieve the layer and the cities MATCH (n) WHERE n.layer = 'cities' RETURN n 7

8

MATCH (m) WHERE m.country = 'CAN RETURN m 9

// Create a relationship between the layer (node) and the cities (nodes) [it seems that there is no connection established between layer and cities] MATCH (n) WHERE n.layer = 'cities' MATCH (m) WHERE m.country = 'CAN' CREATE (n)-[:includes]->(m) // Retrieve all cities (nodes) in layer 'cities' MATCH (n)-[r:includes]->(m) RETURN m 10

// Count all nodes MATCH (n) RETURN count(n) // Nodes that are not part of the spatial index. MATCH (n) WHERE NOT (n)-[:rtree_reference]-() RETURN count(n) 11

MATCH (n) WHERE NOT (n)- [:RTREE_REFERENCE]-() RETURN ID(n) MATCH (n) WHERE NOT (n)- [:RTREE_REFERENCE]-() RETURN n 12

13

// Nodes that are part of the spatial index. MATCH (n) WHERE (n)-[:rtree_reference]-() RETURN count(n) MATCH (n) WHERE (n)-[:rtree_reference]-() RETURN n 14

15

// Non leaf nodes in the tree (1+10) MATCH (n) WHERE (n)-[:rtree_reference]->() RETURN count(n) MATCH (n) WHERE (n)-[:rtree_reference]->() RETURN n 16

MATCH (n) WHERE (n)-[:rtree_reference]->() RETURN n.bbox (distributed across the country) R-tree nodes 17

// Retrieve ids of non-leaf nodes MATCH (n) WHERE (n)-[:rtree_reference]->() RETURN ID(n) (pick one id and find how many children) MATCH (n) WHERE ID(n)=1029 MATCH (n)-[:rtree_reference]->(m) RETURN count(m) 18

MATCH (n) WHERE ID(n)=1132 MATCH (n)-[:rtree_reference]->(m) RETURN m.name // Report city properties MATCH (n) RETURN n.name 19

(WITH is like RETURN; to use values in subsequent commands) MATCH (n) WITH distinct n RETURN n.name MATCH (n) RETURN n.name, n.capital 20

MATCH (n) RETURN n.name, n.latitude, n.longitude MATCH (n) WHERE n.name = 'Toronto' RETURN n.name, n.latitude, n.longitude 21

MATCH (n), (m) WHERE n.name = 'Toronto' AND m.name = 'Fredericton' RETURN n.capital, m.stateabb // Labels - returns all NULL (no labels) MATCH (n) RETURN n:label 22

//Assign labels (Atlantic cities) MATCH (n) where n.longitude > -70 WITH COLLECT (distinct(n)) as nn FOREACH (n in nn SET n:atlantic) MATCH (n) WHERE n:atlantic RETURN n.name as ATLANTIC_CITIES 23

// List of procedures CALL spatial.procedures // Cities within 100km from location CALL spatial.withindistance('cities',{lon:-66.0,lat:45.0},100) 24

CALL spatial.withindistance('cities',{lon:-66.0,lat:45.0},100) YIELD node as n RETURN n // Cities within 100km from Fredericton MATCH (n) WHERE n.name = 'Fredericton' CALL spatial.withindistance('cities',{lon:n.longitude,lat:n.latitude},100) YIELD node as m RETURN m 25

MATCH (n) WHERE n.name = 'Fredericton' CALL spatial.withindistance('cities',{lon:n.longitude,lat:n.latitude},100) YIELD node as m RETURN m.name // Create relationships MATCH (n) WHERE n.name = 'Fredericton' CALL spatial.withindistance('cities',{lon:n.longitude,lat:n.latitude},100) YIELD node as m CREATE (n)-[r:near_fredericton]->(m) 26

MATCH (n) WHERE n.name = 'Fredericton' RETURN n --> see the graph and expand relationships MATCH (n)-[r:near_fredericton]->(m) WHERE n.name = 'Fredericton' RETURN m.name 27

// Create relationships by iteration MATCH (n:atlantic) MATCH (m) WHERE m.name = 'Toronto' MERGE (m)-[:toronto2atlantic]->(n) MATCH (n)-[r:toronto2atlantic]->(m) RETURN m.name 28

// Create relationships by iteration MATCH (m) WHERE m.name in ["Fredericton", "Ottawa", "Calgary"] CALL spatial.withindistance('cities',{lon:m.longitude,lat:m.latitude},100) YIELD node as j MERGE (j)-[:network3cities_near]-(m) MATCH (n)-[r:network3cities_near]->(m) RETURN n.name, m.name 29

// Create network betweeen atlantic cities with a dist < 100km MATCH (m) WHERE m.longitude > -70 CALL spatial.withindistance('cities',{lon:m.longitude,lat:m.latitude},100) YIELD node as j MERGE (j)-[:networkatlantic_near]-(m) MATCH (n)-[r:networkatlantic_near]->(m) RETURN n.name, m.name 30

//A network between capital cities MATCH (n) WHERE n.capital=1 RETURN n.name MATCH (n) WHERE n.capital=1 MATCH (m) WHERE m.capital=1 MERGE (n)-[:networkcapitals]->(m) 31

MATCH (n)-[r:networkcapitals]->(m) RETURN n.name, m.name //Intersection of geometries CALL spatial.intersects('cities','polygon((-70 45, -70 53, -60 55, -60 47, -70 45))') YIELD node as m RETURN m 32

CALL spatial.intersects('cities','polygon((-70 45, -70 53, -60 55, -60 47, -70 45))') YIELD node as m RETURN m.name 33

// Remove layer CALL spatial.removelayer('cities') // Remove all nodes/relationships MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r 34