Giter Club home page Giter Club logo

land-graph's Introduction

Land Graph

Analyzing public lands and US Congress using graphs. Inspired by https://github.com/acannistra/landwatch

One of the most powerful features of graph databases like Neo4j is the ability to combine datasets and query across them. This project combines data about US public lands into a single graph database for analysis using graph data science and graph visualization.

Currently supports the following data sources:

Install

This project uses Poetry for managing Python dependencies and virtual environments.

To use the notebooks:

poetry install
poetry shell
jupyter notebook 

The Data Import Process

First, download the USGS Protected Areas Database. NOTE: You may need to refresh download link here.

wget -O data/region9.zip https://prod-is-usgs-sb-prod-content.s3.amazonaws.com/622256afd34ee0c6b38b6bb7/PADUS3_0_Region_9_GeoJSON.zip\?AWSAccessKeyId\=AKIAI7K4IX6D4QLARINA\&Expires\=1672066494\&Signature\=955c4BEVO7XGRLQlSGyLaWIwqqM%3D

Extract zip file:

unzip data/region9.zip -d data/region9

Next, reproject to WGS84 using ogr2ogr:

ogr2ogr -s_srs ESRI:102039 -t_srs EPSG:4326 -f geojson data/region9/output.json data/region9/PADUS3_0Fee_Region9.json

Set root directory for import to data directory in neo4j.conf

server.directories.import=/Users/lyonwj/github/johnymontana/land-graph/data

Also, increase Neo4j maximum memory heap size in neo4j.conf if needed:

server.memory.heap.max_size=1G

Enable file import with APOC in conf/apoc.conf:

apoc.import.file.enabled=true

// TODO: prepare database for import by creating constraints

CREATE CONSTRAINT FOR (p:Parcel) REQUIRE p.name IS UNIQUE;
CREATE CONSTRAINT FOR (g:Geometry) REQUIRE g.FID IS UNIQUE;

Import in Neo4j using apoc.load.json:

CALL apoc.load.json('file:///region9/output.json') 
YIELD value
UNWIND value.features AS feature
WITH feature WHERE feature.geometry.type = "Polygon"
MERGE (p:Parcel {name: feature.properties.Unit_Nm})
ON CREATE SET 
  p += feature.properties
MERGE (g:Geometry {FID: p.FID})
ON CREATE SET 
  g.coordinates = [coord IN feature.geometry.coordinates[0] | point({latitude: coord[1], longitude: coord[0]})]
MERGE (p)-[:HAS_GEOMETRY]->(g)
SET g:Polygon

Next, to load US Congressional data using the ProPublica API see notebooks/import.ipynb

Visualizing With Neo4j Bloom

land-graph's People

Contributors

johnymontana avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.