├── .DS_Store ├── .gitignore ├── CONTRIBUTING.md ├── CoreConceptsHs ├── .DS_Store ├── .gitignore ├── Event.hs ├── Field.hs ├── Location.hs ├── Makefile ├── Network new.hs ├── Network.hs ├── NetworkExamples.hs ├── NetworkImpl.hs ├── Object.hs ├── README.md └── Time.hs ├── CoreConceptsJs ├── 1.0 │ ├── CcField.js │ ├── CcObject.js │ ├── README.md │ ├── examples │ │ ├── README.md │ │ ├── css │ │ │ └── ex1.css │ │ └── nightlight.html │ └── test │ │ ├── css │ │ ├── test1.css │ │ └── test2.css │ │ ├── test-Field.html │ │ ├── test-Object.html │ │ ├── test-buffer.html │ │ ├── test-coarsen.html │ │ ├── test-local.html │ │ └── test-restrictDomain.html └── 2.0 │ ├── CcEvent.js │ ├── CcField.js │ ├── CcNetwork.js │ ├── CcObject.js │ ├── README.md │ ├── lib │ └── jsnetworkx.js │ └── test │ ├── buffer.html │ ├── coarsen.html │ ├── css │ ├── test1.css │ └── test2.css │ ├── event.html │ ├── field.html │ ├── focal.html │ ├── local.html │ ├── network.html │ ├── object.html │ ├── relation.html │ └── restrictDomain.html ├── CoreConceptsPy ├── .gitignore ├── ArcPy │ ├── README.md │ ├── coreconcepts.py │ ├── examples │ │ └── china_lights │ │ │ ├── china_lights.py │ │ │ ├── coreconcepts.py │ │ │ └── testing.py │ ├── fields.py │ ├── objects.py │ ├── temp │ │ ├── field.py │ │ └── object.py │ └── utils.py ├── Astronomic_Spaces │ ├── case_examples │ │ ├── events │ │ │ ├── 2011fe.csv │ │ │ ├── 2012aw.csv │ │ │ ├── 2012cg.csv │ │ │ └── events_cases.py │ │ ├── fields │ │ │ ├── cases_field.py │ │ │ ├── velocity_field.csv │ │ │ └── velocity_field.tsv │ │ ├── locations_objects │ │ │ ├── cases_location.py │ │ │ ├── cases_object.py │ │ │ └── wk_cepheids.csv │ │ └── sn2017fe.py │ ├── coreconcepts.py │ ├── events.py │ ├── fields.py │ ├── locations.py │ ├── locations_depr.py │ ├── networks.py │ ├── objects.py │ ├── tests │ │ ├── locationtest.py │ │ └── networktest.py │ └── utils.py ├── GdalPy │ ├── Makefile │ ├── README.md │ ├── RdfReader.py │ ├── RdfWriter.py │ ├── __init__.py │ ├── coreconcepts.py │ ├── events.py │ ├── examples │ │ ├── README.md │ │ ├── __init__.py │ │ ├── china_lights │ │ │ ├── README.md │ │ │ ├── china_lights-lowe_2014 │ │ │ │ ├── China_example_Lowe_text_2014.pdf │ │ │ │ ├── China_example_Lowe_text_2014_script.py │ │ │ │ └── China_example_figure.pdf │ │ │ └── china_lights_cc.py │ │ ├── events │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── earthquake │ │ │ │ ├── EarthquakeRdfReader.py │ │ │ │ ├── EarthquakeRdfReader2.py │ │ │ │ ├── EarthquakeRdfWriter.py │ │ │ │ ├── EarthquakeRdfWriter2.py │ │ │ │ ├── README.md │ │ │ │ ├── bindings.json │ │ │ │ ├── earthquake.py │ │ │ │ ├── input_use_case.py │ │ │ │ └── output_use_case.py │ │ │ ├── example_1.py │ │ │ ├── example_2.py │ │ │ └── example_3.py │ │ ├── fields │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── aspectCalc.py │ │ │ ├── slopeCalc.py │ │ │ ├── zonalArea.py │ │ │ └── zonalRadiation.py │ │ ├── locations │ │ │ ├── README.md │ │ │ └── __init__.py │ │ ├── networks │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── karate.py │ │ │ ├── synthetic_weighted_network.py │ │ │ └── ucsb.py │ │ └── objects │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── roofsAboveMinInsolation.py │ │ │ └── selectRooftopsNearRoads.py │ ├── fields.py │ ├── locations.py │ ├── makefile.py │ ├── networks.py │ ├── objects.py │ ├── test │ │ ├── README.md │ │ ├── __init__.py │ │ ├── events_test.py │ │ ├── fields_test.py │ │ ├── networks_test.py │ │ └── objects_test.py │ └── utils.py └── README.md ├── CoreConceptsRdf ├── README.md ├── coreconcepts_rdfs.rdf └── event │ ├── README.md │ ├── event_rdfs.rdf │ ├── event_ttl.owl │ ├── event_xml.owl │ ├── event_xml_2.owl │ └── examples │ ├── README.md │ ├── earthquake │ ├── README.md │ ├── earthquake.rdf │ ├── sparql_queries.md │ └── test.rdf │ └── ontology │ ├── README.md │ ├── owl_ontology.rdf │ ├── owl_ontology_2.rdf │ ├── owl_ontology_3.rdf │ ├── rdfs_ontology.rdf │ ├── sparql_queries.md │ ├── sparql_queries_2.md │ └── sparql_queries_3.md ├── LICENSE ├── Learn.md ├── README.md ├── data ├── README.md ├── events │ ├── README.md │ ├── course_data.csv │ ├── earthquake_data.csv │ └── weather_data.txt ├── fields │ ├── CalPolyDEM.tif │ ├── README.md │ ├── insolation2014.tfw │ ├── insolation2014.tif │ ├── insolation2014.tif.aux.xml │ ├── insolation2014.tif.ovr │ ├── log │ ├── testField.tif │ ├── tmp │ │ ├── outAspect.tfw │ │ ├── outAspect.tif │ │ ├── outAspect.tif.aux.xml │ │ ├── outSlope.aux.xml │ │ ├── outSlope.tfw │ │ ├── outSlope.tif │ │ ├── outSlope.tif.aux.xml │ │ ├── zonalArea.tfw │ │ ├── zonalArea.tif │ │ ├── zonalArea.tif.aux.xml │ │ ├── zonalInsolation.dbf │ │ └── zonalInsolation.dbf.xml │ ├── zonalRast.tfw │ ├── zonalRast.tif │ ├── zonalRast.tif.aux.xml │ ├── zonalRast.tif.ovr │ ├── zonalRast.tif.vat.dbf │ ├── zonalRast.tif.xml │ ├── zonaltable.dbf │ └── zone.tif ├── networks │ ├── README.md │ ├── karate.gml │ └── ucsb.shp │ │ ├── ucsb.cpg │ │ ├── ucsb.dbf │ │ ├── ucsb.prj │ │ ├── ucsb.qpj │ │ ├── ucsb.shp │ │ └── ucsb.shx └── objects │ ├── README.md │ ├── Rooftop.lyr │ ├── Rooftops.dbf │ ├── Rooftops.prj │ ├── Rooftops.shp │ ├── Rooftops.shp.xml │ ├── Rooftops.shx │ ├── ViablePVArea.dbf │ ├── ViablePVArea.prj │ ├── ViablePVArea.sbn │ ├── ViablePVArea.shp │ ├── ViablePVArea.shp.xml │ ├── ViablePVArea.shx │ ├── roads.dbf │ ├── roads.prj │ ├── roads.sbn │ ├── roads.sbx │ ├── roads.shp │ ├── roads.shp.xml │ ├── roads.shx │ ├── rooftops_pv.dbf │ ├── rooftops_pv.prj │ ├── rooftops_pv.sbn │ ├── rooftops_pv.sbx │ ├── rooftops_pv.shp │ ├── rooftops_pv.shx │ └── tmp │ ├── roofs_aboveMinInsol.dbf │ ├── roofs_aboveMinInsol.prj │ ├── roofs_aboveMinInsol.sbn │ ├── roofs_aboveMinInsol.sbx │ ├── roofs_aboveMinInsol.shp │ ├── roofs_aboveMinInsol.shp.xml │ ├── roofs_aboveMinInsol.shx │ ├── roofs_within50mroads.dbf │ ├── roofs_within50mroads.prj │ ├── roofs_within50mroads.sbn │ ├── roofs_within50mroads.sbx │ ├── roofs_within50mroads.shp │ ├── roofs_within50mroads.shp.xml │ └── roofs_within50mroads.shx ├── extras ├── CoreConceptsHs Backup │ ├── .gitignore │ ├── Event.hs │ ├── Field.hs │ ├── Location.hs │ ├── Makefile │ ├── Network.hs │ ├── NetworkExamples.hs │ ├── NetworkImpl.hs │ ├── Object.hs │ ├── README.md │ ├── Theme.hs │ └── Time.hs ├── CoreConceptsHs.sublime-project └── CoreConceptsPy.sublime-project └── figures ├── CoreConceptsArchitecture.png ├── CoreConceptsArchitecture.pptx ├── CoreConceptsCube.pdf ├── CoreConceptsCube_thumbnail.png ├── CoreConceptsLenses.png ├── CoreConceptsLenses_thumbnail.png └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .project 3 | .pydevproject 4 | .settings/org.eclipse.core.resources.prefs 5 | org.eclipse.core.resources.prefs 6 | **/*.sublime-workspace 7 | 8 | **/Thumbs.db 9 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | These contributing guides are subject to change with the next major update to the codebase. 2 | 3 | Conventions 4 | =================== 5 | The following are conventions and resources used throughout the codebase: 6 | - [Background learning resources](Learn.md) (Git, pull-requests, Haskell, Python & RDF are covered) 7 | - `TODO` is used to indicate that something is missing or unfinished. 8 | - `WIP` is used to indicate that something could change any time. 9 | 10 | Style guides 11 | ------------ 12 | The following style guides are currently implemented and expected for contributions: 13 | - [Haskell](https://wiki.haskell.org/Programming_guidelines) 14 | - [Python](https://google.github.io/styleguide/pyguide.html) 15 | 16 | Editors and IDEs 17 | ================ 18 | The following editors and integrated development environments have been used: 19 | - [Sublime Text](https://www.sublimetext.com) [*Text editor with Plugins (recommended)*] 20 | - [PyCharm](https://www.jetbrains.com/pycharm/) [*Python IDE (recommended)*] 21 | - [Smultron](https://www.peterborgapps.com/smultron/) [*OSX Text editor*] 22 | - [Apatana](http://www.aptana.com/) [*Python IDE*] 23 | - [IntelliJ IDEA](https://www.jetbrains.com/idea/) 24 | -------------------------------------------------------------------------------- /CoreConceptsHs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/CoreConceptsHs/.DS_Store -------------------------------------------------------------------------------- /CoreConceptsHs/.gitignore: -------------------------------------------------------------------------------- 1 | # https://github.com/github/gitignore/blob/master/Haskell.gitignore 2 | dist 3 | cabal-dev 4 | *.o 5 | *.hi 6 | *.chi 7 | *.chs.h 8 | *.dyn_o 9 | *.dyn_hi 10 | .virtualenv 11 | .hpc 12 | .hsenv 13 | .cabal-sandbox/ 14 | cabal.sandbox.config 15 | *.prof 16 | *.aux 17 | *.hp 18 | -------------------------------------------------------------------------------- /CoreConceptsHs/Event.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | {-# LANGUAGE FlexibleInstances #-} 3 | 4 | -- the content concept of an event 5 | -- core questions: when did this event happen? what happened before? what participants does the event have? 6 | -- events are instantiated process portions with fields, objects, and networks as participants 7 | -- an event collection is an event (in analogy to a feature collection being a feature) 8 | -- (c) Werner Kuhn 9 | -- latest change: Feb 6, 2016 10 | -- To Do 11 | -- compute event outcomes: central, but how to specify? do simple examples 12 | 13 | module Event where 14 | 15 | import Time 16 | 17 | -- the class of all event types 18 | -- Eq captures identity 19 | -- events are bounded in time, but do not need an explicit boundary 20 | class Eq (event time) => EVENTS event time where 21 | bounds :: event time -> Interval time 22 | 23 | data InstantEvent time = InstantEvent (Instant time) deriving (Eq, Show) 24 | 25 | instance (Eq time, Ord time) => EVENTS InstantEvent time where 26 | bounds (InstantEvent (Instant t1 trs1)) = Interval (Instant t1 trs1) (Instant t1 trs1) 27 | 28 | -- TESTS 29 | ie1, ie2 :: InstantEvent Int 30 | ie1 = InstantEvent i1 31 | ie2 = InstantEvent i2 32 | et1 = bounds ie1 -------------------------------------------------------------------------------- /CoreConceptsHs/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Core Concepts Haskell library 3 | # 4 | # ====== VARIABLES ====== 5 | 6 | # ====== TARGETS ====== 7 | all: 8 | @echo "Select an option."; 9 | @cat Makefile; 10 | @echo "\n"; 11 | 12 | clean: 13 | @rm -rf *.hi **/*.hi *.o **/*.o; 14 | 15 | test-events: clean 16 | @echo "No examples and no tests for events yet." 17 | 18 | test-fields: clean 19 | @echo "No examples and no tests for fields yet." 20 | 21 | test-locations: clean 22 | @echo "No examples and no tests for locations yet." 23 | 24 | test-networks: clean 25 | @echo "No tests for networks yet. Have a look at the examples." 26 | 27 | test-objects: clean 28 | @echo "No examples and no tests for objects yet." 29 | 30 | test-all: test-events test-fields test-locations test-networks test-objects 31 | 32 | example-events: clean 33 | @echo "No examples and no tests for events yet." 34 | 35 | example-fields: clean 36 | @echo "No examples and no tests for fields yet." 37 | 38 | example-locations: clean 39 | @echo "No examples and no tests for locations yet." 40 | 41 | example-networks: clean 42 | runhaskell NetworkExamples.hs 43 | 44 | example-objects: clean 45 | @echo "No examples for objects yet. Have a look at the tests." 46 | 47 | example-all: example-events example-fields example-locations example-networks example-objects 48 | 49 | install-dependencies: 50 | # for Linux/Mac 51 | cabal install fgl; 52 | -------------------------------------------------------------------------------- /CoreConceptsHs/Network.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | {-# LANGUAGE TypeSynonymInstances #-} 3 | {-# LANGUAGE FlexibleInstances #-} 4 | {-# LANGUAGE FunctionalDependencies #-} 5 | 6 | -- the content concept of a network 7 | -- core question: are two nodes connected? what is the shortest path between them? 8 | -- how to bring in PATH and LINK from earlier specs? 9 | -- (c) Werner Kuhn 10 | -- latest change: Feb 27, 2016 11 | 12 | -- TO DO 13 | -- make networks a subclass of objects 14 | -- Graph representation in FGL 15 | -- also, use FGL to determine core queries 16 | 17 | 18 | module Network where 19 | 20 | -- the class of all network types 21 | -- both nodes and edges can be labeled 22 | class NETWORK network node edge | network -> node, network -> edge where 23 | nodes :: network -> [node] 24 | edges :: network -> [edge] 25 | addNode :: network -> node -> network 26 | addEdge :: network -> edge -> network -- link existing nodes 27 | degree :: network -> node -> Int -- number of edges to other nodes 28 | connected :: network -> node -> node -> Bool -- can the second node be reached from the first? 29 | shortestPath :: network -> node -> node -> [edge] 30 | distance :: network -> node -> node -> Int -- length of the shortest path as number of nodes 31 | breadthFirst :: network -> node -> Int -> [node] -- all nodes at distance Int from a node 32 | 33 | -------------------------------------------------------------------------------- /CoreConceptsHs/NetworkImpl.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE FlexibleContexts #-} 2 | {-# LANGUAGE FlexibleInstances #-} 3 | {-# LANGUAGE MultiParamTypeClasses #-} 4 | {-# LANGUAGE TypeSynonymInstances #-} 5 | 6 | -- implementation for core concept: network 7 | -- (c) Michel Zimmer 8 | -- latest change: Mar 11, 2015 9 | 10 | module NetworkImpl where 11 | 12 | import Network 13 | import Data.List 14 | import Data.Maybe 15 | import Data.Graph.Inductive.Graph 16 | import Data.Graph.Inductive.PatriciaTree 17 | import Data.Graph.Inductive.Query.BFS 18 | 19 | type Node = Data.Graph.Inductive.Graph.Node 20 | type Weight = Int 21 | type Edge = Data.Graph.Inductive.Graph.LEdge Weight 22 | type CCGraph = Gr () Weight 23 | 24 | instance NETWORK CCGraph NetworkImpl.Node NetworkImpl.Edge where 25 | nodes = map fst . labNodes 26 | edges = labEdges 27 | addNode graph node = insNode (node, ()) graph 28 | addEdge = flip $ insEdge 29 | degree = deg 30 | connected graph a b = 0 /= distance graph a b 31 | shortestPath graph a b = map label edges 32 | where 33 | label :: Data.Graph.Inductive.Graph.Edge -> NetworkImpl.Edge 34 | label (a, b) = (a, b, 1) 35 | edges :: [Data.Graph.Inductive.Graph.Edge] 36 | edges = zip path $ tail path 37 | path :: [NetworkImpl.Node] 38 | path = esp a b graph 39 | distance graph a b = length $ shortestPath graph a b 40 | breadthFirst graph node distance = map fst $ filter select $ level node graph 41 | where 42 | select :: (NetworkImpl.Node, Int) -> Bool 43 | select (_, d) = d <= distance 44 | 45 | mkGraph :: [NetworkImpl.Node] -> [NetworkImpl.Edge] -> CCGraph 46 | mkGraph nodes ledges = Data.Graph.Inductive.Graph.mkGraph (map label nodes) ledges 47 | where 48 | label :: NetworkImpl.Node -> LNode () 49 | label node = (node, ()) 50 | -------------------------------------------------------------------------------- /CoreConceptsHs/Object.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | 3 | -- the content concept of an object 4 | -- core questions: where is this object? is it the same as that object? 5 | -- collections of objects are objects too (consistent with feature collections being features in OGC) 6 | -- objects have temporal state (manifested in their spatial and thematic properties and relations) 7 | -- (c) Werner Kuhn 8 | -- latest change: July 24, 2016 9 | 10 | -- TO DO 11 | -- consider boundedness by upper hierarchy level of a tesselation (AURIN does that?) 12 | -- make FIELDS a subclass of OBJECTS 13 | 14 | module Object where 15 | 16 | import Location 17 | 18 | -- the class of all object types 19 | -- Eq captures identity (each object type has its own identity criterion) 20 | -- all objects are bounded, but they may not have a boundary 21 | -- object properties and relations to be defined on concrete object types (none are generic) 22 | class Eq object => OBJECTS object where 23 | bounds :: object -> Location -- need to differentiate object geometry from object boundary 24 | 25 | -- object IDs (for types that use one) 26 | newtype Id = Id Int deriving (Eq, Show) 27 | 28 | -- points of interest 29 | data POI = POI Id Position deriving Show 30 | instance Eq POI where 31 | POI i p == POI j q = i == j 32 | instance OBJECTS POI where 33 | bounds (POI i p) = Location p [] 34 | 35 | -- tests 36 | poi1, poi2 :: POI 37 | poi1 = POI (Id 1) p11 38 | poi2 = POI (Id 2) p22 39 | ot1 = bounds poi1 40 | -------------------------------------------------------------------------------- /CoreConceptsHs/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Haskell 2 | ============================================== 3 | 4 | Abstract: Specifications and implementation of the core concepts in Haskell. 5 | 6 | See the [Readme](../README.md) in the parent directory for general information about the Core Concepts. 7 | 8 | Currently, the implementation is in a proof of concept state and should not be considered stable for a production environment. 9 | 10 | Contents 11 | ---------------------- 12 | 13 | - `Event.hs`: Specifications of events. 14 | - `Field.hs`: Specifications of fields. 15 | - `Location.hs`: Specifications of locations. 16 | - `Makefile`: Common commands for unix platforms. 17 | - `NetworkExamples.hs`: Examples for networks. 18 | - `Network.hs`: Specifications of networks. 19 | - `NetworkImpl.hs`: Implementations of networks. 20 | - `Object.hs`: Specifications of objects. 21 | 22 | How to test the code and run the examples 23 | ----------------------------------------- 24 | 25 | ### Unix/Linux platforms 26 | To run the Unit Tests execute: `make test-all` 27 | 28 | To run the examples execute: `make example-all` 29 | 30 | Dependencies 31 | ---------------------- 32 | - [FGL](https://hackage.haskell.org/package/fgl) (Version: latest*) 33 | 34 | \* Most recent stable release on package 35 | 36 | ### Unix/Linux platforms 37 | To install the dependencies execute: `make install-dependencies` 38 | -------------------------------------------------------------------------------- /CoreConceptsHs/Time.hs: -------------------------------------------------------------------------------- 1 | -- basic time values and operations for core concepts 2 | -- (c) Werner Kuhn 3 | -- latest change: October 7, 2016 4 | 5 | -- TO DO 6 | 7 | module Time where 8 | 9 | import Data.Time -- Haskell's time library, see http://two-wrongs.com/haskell-time-library-tutorial 10 | 11 | type Instant = UTCTime 12 | ts = (read "2016-07-01 19:16 UTC") :: Instant -- an arbitrary time stamp 13 | 14 | type Duration = DiffTime 15 | 16 | type Period = (Instant, Instant) 17 | 18 | instantIn :: Instant -> Period -> Bool 19 | instantIn i p = (fst p) <= i && (snd p) >= i 20 | -------------------------------------------------------------------------------- /CoreConceptsJs/1.0/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - JavaScript 2 | ================================================= 3 | 4 | **Abstract**: A JavaScript implementation of the core concepts. 5 | This JavaScript API is designed to provide experts outside GIS domain an easy-to-use spatial computing library over the Web. 6 | 7 | **Note**: This version of implementation is built on top of `ArcGIS JavaScript API 3.x`. 8 | It may be not compatible with ArcGIS JavaScript API 4.x. Please refer to [version 2.0](../2.0/) for more information. 9 | 10 | Contents 11 | ---------------------- 12 | - [`examples/`](examples): Usage examples of implementations. 13 | - [`test/`](test): Unit tests. 14 | - `CcField.js`: Implementations of fields. 15 | - `CcObject.js`: Implementations of objects. 16 | 17 | Use the API 18 | ----------------------------------------- 19 | 20 | #### 1. Configure Dojo with dojoConfig 21 | ``` 22 | 23 | 35 | ``` 36 | \* Keep in mind you must set the dojoConfig variable before loading ArcGIS JS API 37 | #### 2. Reference the ArcGIS API for JavaScript 38 | Use a second \ to load the ArcGIS API for JavaScript from CDN 39 | ``` 40 | 41 | ``` 42 | #### 3. Load modules 43 | Use `require` to load specific modules from the API. The first parameter to `require` is an array of module ids 44 | — identifiers for the modules you want to load, and the second parameter is a callback function. 45 | ``` 46 | 49 | ``` 50 | \* You can also get started by taking a look at test files or examples. 51 | 52 | Dependencies 53 | ---------------------- 54 | - [ArcGIS JavaScript API] (https://developers.arcgis.com/javascript/3/) (Version: 3.x) 55 | - [Dojo] (http://dojotoolkit.org/) 56 | 57 | \* Dojo is included with the ArcGIS JavaScript API so there is no need to host/reference/install it. 58 | -------------------------------------------------------------------------------- /CoreConceptsJs/1.0/examples/css/ex1.css: -------------------------------------------------------------------------------- 1 | html, body, #map { 2 | height: 100%; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | #leftPanel { 8 | margin: 5px; 9 | background: #fff; 10 | color: #444; 11 | font-family: arial; 12 | width: 200px; 13 | border-right: solid 1px #888; 14 | } 15 | 16 | #status { 17 | background-color: #E0E0E0; 18 | color: #CD0000; 19 | font-weight: bold; 20 | padding: 3px; 21 | border: solid 1px #CD0000; 22 | -moz-border-radius: 5px; 23 | -webkit-border-radius: 5px; 24 | border-radius: 5px; 25 | position: absolute; 26 | top: 50%; 27 | right: 50%; 28 | z-index: 100; 29 | display: none; 30 | height: 20px; 31 | } -------------------------------------------------------------------------------- /CoreConceptsJs/1.0/test/css/test1.css: -------------------------------------------------------------------------------- 1 | html, body, #map { 2 | height: 100%; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | #leftPanel { 8 | margin: 5px; 9 | background: #fff; 10 | color: #444; 11 | font-family: arial; 12 | width: 200px; 13 | border-right: solid 1px #888; 14 | } -------------------------------------------------------------------------------- /CoreConceptsJs/1.0/test/css/test2.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | height: 100%; 3 | width: 100%; 4 | margin: 0; 5 | padding: 0; 6 | } 7 | 8 | h3 { 9 | margin: 0 0 5px 0; 10 | border-bottom: 1px solid #444; 11 | } 12 | 13 | .shadow { 14 | -moz-box-shadow: 0 0 5px #888; 15 | -webkit-box-shadow: 0 0 5px #888; 16 | box-shadow: 0 0 5px #888; 17 | } 18 | 19 | #map { 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | #leftPanel { 25 | margin: 5px; 26 | background: #fff; 27 | color: #444; 28 | font-family: arial; 29 | width: 250px; 30 | border-right: solid 1px #888; 31 | } 32 | 33 | #status { 34 | background-color: #E0E0E0; 35 | color: #707070; 36 | font-weight: bold; 37 | padding: 3px; 38 | border: solid 1px #707070; 39 | -moz-border-radius: 5px; 40 | -webkit-border-radius: 5px; 41 | border-radius: 5px; 42 | position: absolute; 43 | top: 50%; 44 | right: 50%; 45 | z-index: 100; 46 | display: none; 47 | height: 20px; 48 | } -------------------------------------------------------------------------------- /CoreConceptsJs/1.0/test/test-Field.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CcField test 7 | 8 | 9 | 10 | 11 | 12 | 13 | 21 | 22 | 23 | 24 | 41 | 42 | 43 |
44 | 45 | -------------------------------------------------------------------------------- /CoreConceptsJs/1.0/test/test-Object.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CcObject test 7 | 8 | 9 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | 23 | 48 | 49 | 50 |
51 | 52 | -------------------------------------------------------------------------------- /CoreConceptsJs/1.0/test/test-buffer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Test buffer function 7 | 8 | 9 | 10 | 11 | 12 | 13 | 22 | 23 | 24 | 25 | 66 | 67 | 68 |
69 | 70 | -------------------------------------------------------------------------------- /CoreConceptsJs/1.0/test/test-coarsen.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | coarsen function test 7 | 8 | 9 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | 23 | 58 | 59 | 60 | 61 | 62 |
65 | 66 |
67 |
68 | 69 |
70 |
71 | Cell Width:
72 |
73 | Cell Height:
74 |

75 | 76 |

77 |
78 | 79 |
80 |
81 | 82 | -------------------------------------------------------------------------------- /CoreConceptsJs/2.0/CcEvent.js: -------------------------------------------------------------------------------- 1 | /** 2 | * JavaScript implementation of the core concept 'event'. 3 | * version: 2.0.0 4 | * (c) Liangcun Jiang 5 | * latest change: July 30, 2017. 6 | * Dev notes: 7 | */ 8 | define([ 9 | "dojo/_base/declare", 10 | "dojo/domReady!" 11 | ], function (declare) { 12 | //null signifies that this class has no classes to inherit from 13 | return declare(null, { 14 | /** 15 | * Event constructor: Constructs an event instance 16 | * @param id: the identity of an event. 17 | * @param period: {start: JS Date object, end: JS Date object} 18 | * @param participants: an array of participants of this event (e.g. CcField, CcObject, CcNetwork), 19 | * @param opt: optional parameters 20 | */ 21 | constructor: function (id, period, participants, opt) { 22 | this.id = id; 23 | this.start = period.start; 24 | this.end = period.end; 25 | this.participants = participants; 26 | this.props = opt; 27 | }, 28 | 29 | /** 30 | * Event function: returns a Period 31 | */ 32 | within: function () { 33 | return [this.start, this.end]; 34 | }, 35 | 36 | /** 37 | * Event function: returns the start time of this event 38 | */ 39 | when: function () { 40 | return this.start; 41 | }, 42 | 43 | /** 44 | * Event function: returns true if the event happened during another event e. 45 | * Return type: Boolean 46 | */ 47 | during: function (e) { 48 | return e.start <= this.start && this.end <= e.end; 49 | }, 50 | 51 | /** 52 | * Event function: returns true if the event happened before another event e. 53 | * Return type: Boolean 54 | */ 55 | before: function (e) { 56 | return this.end <= e.start; 57 | }, 58 | 59 | /** 60 | * Event function: returns true if the event happened after another event e. 61 | * Return type: Boolean 62 | */ 63 | after: function (e) { 64 | return e.end <= this.start; 65 | }, 66 | 67 | /** 68 | * Event function: returns true if the event overlaps another event e. 69 | * Return type: Boolean 70 | */ 71 | overlap: function (e) { 72 | return this.end > e.start || e.end > this.start; 73 | } 74 | }); 75 | }); 76 | -------------------------------------------------------------------------------- /CoreConceptsJs/2.0/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - JavaScript 2 | ================================================= 3 | 4 | **Abstract**: A JavaScript implementation of the core concepts. 5 | This JavaScript API is designed to provide experts outside GIS domain an easy-to-use spatial computing library over the Web. 6 | It is built on top of `ArcGIS JavaScript API 4.x`, and uses Dojo toolkit to ensure simplicity and efficiency. 7 | 8 | See the [Readme](../../README.md) in the parent directory for general information about the Core Concepts. 9 | 10 | Contents 11 | ---------------------- 12 | - [`examples/`](examples): Usage examples of implementations. 13 | - [`test/`](test): Unit tests. (WIP) 14 | - `CcField.js`: Implementations of fields. 15 | - `CcObject.js`: Implementations of objects. 16 | 17 | Use the API 18 | ----------------------------------------- 19 | 20 | #### 1. Configure Dojo with dojoConfig 21 | ``` 22 | 23 | 34 | ``` 35 | \* Keep in mind you must set the dojoConfig variable before loading ArcGIS JS API 36 | #### 2. Reference the ArcGIS API for JavaScript 37 | Use a second \ to load the ArcGIS API for JavaScript from CDN 38 | ``` 39 | 40 | ``` 41 | #### 3. Load modules 42 | Use `require` to load specific modules from the API. The first parameter to `require` is an array of module ids 43 | — identifiers for the modules you want to load, and the second parameter is a callback function. 44 | ``` 45 | 48 | ``` 49 | \* You can also get started by taking a look at test files or examples. 50 | 51 | Dependencies 52 | ---------------------- 53 | - [ArcGIS JavaScript API] (https://developers.arcgis.com/javascript/) (latest version) 54 | - [Dojo] (http://dojotoolkit.org/) 55 | 56 | \* Dojo is included with the ArcGIS JavaScript API so there is no need to host/reference/install it. 57 | -------------------------------------------------------------------------------- /CoreConceptsJs/2.0/test/buffer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Test buffer function 7 | 8 | 9 | 10 | 11 | 12 | 21 | 22 | 23 | 24 | 74 | 75 | 76 |
77 | 78 | -------------------------------------------------------------------------------- /CoreConceptsJs/2.0/test/css/test1.css: -------------------------------------------------------------------------------- 1 | html, body, #viewDiv { 2 | height: 100%; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | #leftPanel { 8 | margin: 5px; 9 | background: #fff; 10 | color: #444; 11 | font-family: arial; 12 | width: 200px; 13 | border-right: solid 1px #888; 14 | } -------------------------------------------------------------------------------- /CoreConceptsJs/2.0/test/css/test2.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | height: 100%; 3 | width: 100%; 4 | margin: 0; 5 | padding: 0; 6 | } 7 | 8 | h3 { 9 | margin: 0 0 5px 0; 10 | border-bottom: 1px solid #444; 11 | } 12 | 13 | .shadow { 14 | -moz-box-shadow: 0 0 5px #888; 15 | -webkit-box-shadow: 0 0 5px #888; 16 | box-shadow: 0 0 5px #888; 17 | } 18 | 19 | #map { 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | #viewDiv { 25 | margin: 0; 26 | padding: 0; 27 | } 28 | 29 | #leftPanel { 30 | margin: 5px; 31 | background: #fff; 32 | color: #444; 33 | font-family: arial; 34 | width: 250px; 35 | border-right: solid 1px #888; 36 | } 37 | 38 | #status { 39 | background-color: #E0E0E0; 40 | color: #707070; 41 | font-weight: bold; 42 | padding: 3px; 43 | border: solid 1px #707070; 44 | -moz-border-radius: 5px; 45 | -webkit-border-radius: 5px; 46 | border-radius: 5px; 47 | position: absolute; 48 | top: 50%; 49 | right: 50%; 50 | z-index: 100; 51 | display: none; 52 | height: 20px; 53 | } -------------------------------------------------------------------------------- /CoreConceptsJs/2.0/test/field.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Create a field 7 | 8 | 9 | 10 | 11 | 12 | 20 | 21 | 22 | 23 | 51 | 52 | 53 |
54 | 55 | -------------------------------------------------------------------------------- /CoreConceptsJs/2.0/test/focal.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | focal function test 7 | 8 | 9 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | 23 | 60 | 61 | 62 | 63 | 64 |
67 | 68 |
69 |
70 | 71 |
72 |
73 | kernelColumns:
74 |
75 | kernelRows:
76 |

77 | 78 |

79 |
80 | 81 |
82 |
83 | 84 | -------------------------------------------------------------------------------- /CoreConceptsJs/2.0/test/object.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CcObject test 7 | 8 | 9 | 10 | 11 | 12 | 19 | 20 | 21 | 22 | 56 | 57 | 58 |
59 | 60 | -------------------------------------------------------------------------------- /CoreConceptsJs/2.0/test/restrictDomain.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | restrictDomain function test 8 | 9 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 23 | 24 | 63 | 64 | 65 | 66 |
67 | 68 | -------------------------------------------------------------------------------- /CoreConceptsPy/.gitignore: -------------------------------------------------------------------------------- 1 | tmp/ 2 | 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__/ 5 | *.py[cod] 6 | 7 | # C extensions 8 | *.so 9 | 10 | # Distribution / packaging 11 | .Python 12 | env/ 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | 45 | # Translations 46 | *.mo 47 | *.pot 48 | 49 | # Django stuff: 50 | *.log 51 | 52 | # Sphinx documentation 53 | docs/_build/ 54 | 55 | # PyBuilder 56 | target/ 57 | -------------------------------------------------------------------------------- /CoreConceptsPy/ArcPy/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Python (ArcPy) 2 | ============================================= 3 | 4 | Abstract: A Python implementation of the core concepts leveraging ArcPy processing. 5 | 6 | The implementation is divided into abstract definitions (`coreconcepts.py`), 7 | implementation of one core concept per file (`objects.py` and `fields.py`) 8 | 9 | See the [Readme](../../README.md) in the parent directory for general information about the Core Concepts. 10 | 11 | Right now the implementation is in a proof of concept state and should not be considered stable for a production environment. 12 | 13 | Contents 14 | ---------------------- 15 | 16 | - `coreconcepts.py`: Abstract concepts. 17 | - `examples/`: Usage examples of implementations. 18 | - `fields.py`: Implementations of fields. 19 | - `objects.py`: Implementations of objects. 20 | - `utils.py`: Utilities. 21 | -------------------------------------------------------------------------------- /CoreConceptsPy/ArcPy/examples/china_lights/china_lights.py: -------------------------------------------------------------------------------- 1 | from ../utils import * # TODO: Package up Cc 2 | from ../coreconcepts import * 3 | 4 | china_boundary_filepath = r"China.shp" 5 | china_lights_1_filepath = r"F101994.tif" 6 | china_lights_2_filepath = r"F121994.tif" 7 | gas_flares_filepath = r"Flares_China_1.shp" 8 | china_roads_filepath = r"china_roads.shp" 9 | 10 | # TODO: determine how to chain following methods when different objects return (syntax adjustment?) 11 | 12 | # create fields & objects from file path 13 | china_boundary = make_object(china_boundary_filepath) 14 | china_lights_1 = make_field(china_lights_1_filepath).restrict_domain(china_boundary, 'inside') 15 | china_lights_2 = make_field(china_lights_2_filepath).restrict_domain(china_boundary, 'inside') 16 | gas_flares = make_object(gas_flares_filepath) 17 | 18 | # average fields 19 | average_luminosity = china_lights_1.local(china_lights_2, 'average') 20 | 21 | # remove gas flares 22 | luminosity = average_luminosity.restrict_domain(gas_flares, 'outside') 23 | 24 | # create roads buffer 25 | roads = make_object(china_roads_filepath) 26 | roads_buffered = roads.buffer(0.5, 'DecimalDegrees') # TODO: update function calling convention (exclude object) 27 | 28 | # restrict domain of luminosity to road buffer 29 | luminosity_around_roads = luminosity.restrict_domain(roads_buffered, 'inside') 30 | 31 | # aggregate previous information 32 | results = luminosity_around_roads.coarsen(0.1, 0.1) 33 | -------------------------------------------------------------------------------- /CoreConceptsPy/ArcPy/examples/china_lights/testing.py: -------------------------------------------------------------------------------- 1 | from coreconcepts import * # TODO: Package up Cc 2 | 3 | 4 | china_boundary_filepath = r"C:\Users\lafia\Documents\GitHub\ConceptsOfSpatialInformation\CoreConceptsPy\ArcPy\data\China.shp" 5 | china_lights_1_filepath = r"C:\Users\lafia\Documents\GitHub\ConceptsOfSpatialInformation\CoreConceptsPy\ArcPy\data\F101994.tif" 6 | china_lights_2_filepath = r"C:\Users\lafia\Documents\GitHub\ConceptsOfSpatialInformation\CoreConceptsPy\ArcPy\data\F121994.tif" 7 | gas_flares_filepath = r"C:\Users\lafia\Documents\GitHub\ConceptsOfSpatialInformation\CoreConceptsPy\ArcPy\data\Flares_China_1.shp" 8 | china_roads_filepath = r"data/china_roads.shp" 9 | 10 | # TODO: determine how to chain following methods when different objects return (syntax adjustment?) 11 | 12 | # create fields & objects from file path 13 | china_boundary = makeObject(china_boundary_filepath) 14 | china_lights_1 = makeField(china_lights_1_filepath).restrict_domain(china_boundary, 'inside') 15 | china_lights_2 = makeField(china_lights_2_filepath).restrict_domain(china_boundary, 'inside') 16 | gas_flares = makeObject(gas_flares_filepath) 17 | 18 | # average fields 19 | average_luminosity = china_lights_1.local(china_lights_2, 'average') 20 | 21 | # remove gas flares 22 | luminosity = average_luminosity.restrict_domain(gas_flares, 'outside') 23 | 24 | # create roads buffer 25 | roads = makeObject(china_roads_filepath) 26 | roads_buffered = roads.buffer(0.5, 'DecimalDegrees') # TODO: updated function calling convention (exclude object) 27 | 28 | # restrict domain of luminosity to road buffer 29 | luminosity_around_roads = luminosity.restrict_domain(roads_buffered, 'inside') 30 | 31 | # aggregate previous information 32 | results = luminosity_around_roads.coarsen(0.1, 0.1) 33 | -------------------------------------------------------------------------------- /CoreConceptsPy/ArcPy/objects.py: -------------------------------------------------------------------------------- 1 | import os 2 | from coreconcepts import CcObject 3 | 4 | class ArcShpObject(CcObject): 5 | """ 6 | Concrete class for core concept 'object' 7 | For handling .shp files 8 | """ 9 | def __init__( self, filepath, objIndex, domain ): 10 | super(ArcShpObject, self).__init__(filepath, objIndex, domain) 11 | self.filepath = filepath 12 | self.sObj = objIndex 13 | self.domain = domain 14 | self.filename = os.path.basename(filepath) 15 | 16 | def buffer ( self, distance, unitType ): 17 | """ 18 | Buffer input object 19 | @param distance a distance extent to buffer 20 | @param unitType unit type (ie. decimal degrees, feet) 21 | """ 22 | 23 | outcome = "\_buffer_" 24 | # determine save file path 25 | outputLocation = self.filepath + outcome + self.filename 26 | 27 | # calculate buffer 28 | concatDistance = str(distance) + " " + unitType 29 | arcpy.Buffer_analysis(self.filename, outputLocation, concatDistance) 30 | 31 | # update cc instance's attributes 32 | desc = arcpy.Describe(outputLocation) 33 | self.domain = desc.extent 34 | self.filepath = outputLocation 35 | self.filename = os.path.basename(outputLocation) 36 | 37 | return self 38 | 39 | def relation( self, obj, rel_type ): 40 | raise NotImplementedError("relation") 41 | 42 | def bounds( self ): 43 | raise NotImplementedError("bounds") 44 | 45 | def property( self, prop ): 46 | raise NotImplementedError("property") 47 | 48 | def identity( self, obj ): 49 | raise NotImplementedError("identity") 50 | -------------------------------------------------------------------------------- /CoreConceptsPy/ArcPy/temp/field.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from coreconcepts import CcField 4 | 5 | 6 | class GeoTiffField(CcField): 7 | """ 8 | Concrete class for core concept 'field' 9 | For handling .tiff files 10 | """ 11 | 12 | def __init__(self, filepath, geo_object): 13 | super(GeoTiffField, self).__init__(filepath, geo_object) # TODO: check if syntax is correct for returning type (make sure __init__ is correct) 14 | self.filepath = filepath 15 | self.domain = geo_object 16 | self.filename = os.path.basename(filepath) 17 | 18 | def value_at(self, value_at): 19 | # TODO: return value at current position (must integrate with other operations) 20 | raise NotImplementedError("value at") 21 | 22 | def domain(self): 23 | return super 24 | 25 | def restrict_domain(self, domain_obj, operation): 26 | """ 27 | Restricts current instance's domain based on object's domain 28 | @param domain_obj an object to be subtracted to the current domain 29 | @param operation an operation to be performed based on the object 30 | """ 31 | if operation == 'inside': 32 | # arcpy.env.snapRaster = self.filepath #TODO: will resolve output shift 33 | 34 | # extract by mask 35 | output = arcpy.sa.ExtractByMask(self.filename, domain_obj.filename) 36 | 37 | # determine save credentials 38 | (nfilepath, nfilename) = os.path.split(self.filepath) 39 | outputLocation = nfilepath + "\_masked_" + nfilename 40 | output.save(outputLocation) 41 | 42 | # and update cc instance's attributes 43 | desc = arcpy.Describe(outputLocation) 44 | self.domain = desc.extent 45 | self.filepath = outputLocation 46 | self.filename = os.path.basename(outputLocation) 47 | elif operation == 'ouside': 48 | # TODO: implement outside computations (similar to erase) 49 | raise NotImplementedError("restrict domain 'outside'") 50 | pass 51 | 52 | # TODO: return 'self' 53 | 54 | def local(self, fields, operation): # TODO: fields is a list, make it one 55 | """ 56 | Uses raster calculator from ArcPy 57 | @param fields a field to be subtracted to the current domain 58 | @param operation an operation to be performed based on the field 59 | """ 60 | if operation == 'average': 61 | # perform averaging operation # TODO: generalize funtion for more than two fields 62 | output = (Float(self.filepath)+ Float(fields.filepath))/2 63 | # determine save credentials 64 | (nfilepath, nfilename) = os.path.split(self.filepath) 65 | outputLocation = nfilepath + "\_averaged" + nfilename 66 | output.save(outputLocation) 67 | 68 | # and update cc instance's attributes 69 | desc = arcpy.Describe(outputLocation) 70 | self.domain = desc.extent 71 | self.filepath = outputLocation 72 | self.filename = os.path.basename(outputLocation) 73 | elif operation == 'maximum': 74 | # TODO complete list of local operations 75 | # output = (Float(self.filepath)+Float(fields.filepath))/2 76 | raise NotImplementedError("local 'maximum'") 77 | 78 | else: 79 | print 'the input function is not defined' 80 | 81 | #return output 82 | -------------------------------------------------------------------------------- /CoreConceptsPy/ArcPy/temp/object.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from coreconcepts import CcObject 4 | 5 | 6 | class ArcShpObject(CcObject): 7 | """ 8 | Concrete class for core concept 'object' 9 | For handling .shp files 10 | """ 11 | 12 | def __init__(self, filepath, obj_index, domain): 13 | super(ArcShpObject, self).__init__(filepath, obj_index, domain) 14 | self.filepath = filepath 15 | self.sObj = obj_index 16 | self.domain = domain 17 | self.filename = os.path.basename(filepath) 18 | 19 | def buffer(self, object, distance): 20 | """ 21 | Buffer input object 22 | @param object an object to buffer 23 | @param distance a distance extent to buffer 24 | """ 25 | output = arcpy.Buffer_analysis(self.filename, object.filenameFull) 26 | # TODO: implement saving and updating credentials (see other methods) 27 | raise NotImplementedError("buffer") 28 | 29 | 30 | def relation( self, obj, rel_type ): 31 | pass 32 | 33 | def bounds( self ): 34 | pass 35 | 36 | def property( self, prop ): 37 | pass 38 | 39 | def identity( self, obj ): 40 | pass 41 | -------------------------------------------------------------------------------- /CoreConceptsPy/ArcPy/utils.py: -------------------------------------------------------------------------------- 1 | # make CcField instance (factory) 2 | from field import GeoTiffField 3 | from object import ArcShpObject 4 | 5 | from arcpy import Describe 6 | 7 | 8 | def make_field(filepath): 9 | """ 10 | :param filepath: data source file path 11 | :return: new Ccfield instance 12 | """ 13 | domain = determine_domain(filepath) # determine domain 14 | # determine input file type 15 | if filepath.endswith(".tif"): 16 | return GeoTiffField(filepath, domain) 17 | elif filepath.endswith(".mp3"): 18 | pass 19 | assert 0, "Bad shape creation: " + filepath 20 | 21 | 22 | def make_object(filepath): 23 | """ 24 | :param filepath: data source file path 25 | :return: new Ccobject instance 26 | """ 27 | domain = determine_domain(filepath) # determine domain 28 | # determine input file type 29 | if filepath.endswith(".shp"): 30 | return ArcShpObject(filepath, 1, domain) # TODO: alter objIndex 31 | elif filepath.endswith(".mp3"): 32 | pass 33 | assert 0, "Bad shape creation: " + filepath 34 | 35 | 36 | def determine_domain(filepath): 37 | """ 38 | :param filepath: data source filepath 39 | :return: ArcPy domain extent 40 | """ 41 | desc = arcpy.Describe(filepath) 42 | return desc.extent 43 | 44 | # TODO: Integrate geoEvent & other cc elements into instance creation 45 | # TODO: Refactor code via methods mentioned in other TODOs (separate by file; determine imports) 46 | -------------------------------------------------------------------------------- /CoreConceptsPy/Astronomic_Spaces/case_examples/events/2012aw.csv: -------------------------------------------------------------------------------- 1 | JD,Bmag,Vmag,Rcmag,Icmag,Tel 2 | 6072.3727,13.035,12.893,12.711,12.582,"ANS 157" 3 | 6072.3967,,12.852,,12.492,"ANS 11 " 4 | 6073.4303,12.849,12.636,12.480,12.392,"ANS 157" 5 | 6074.3370,12.761,12.539,12.344,12.320,"ANS 11 " 6 | 6076.3644,12.485,12.310,12.097,12.073,"ANS 157" 7 | 6078.3677,12.298,12.146,11.929,11.951,"ANS 157" 8 | 6080.3689,12.223,12.026,11.890,11.859,"ANS 157" 9 | 6084.3318,12.184,11.975,11.801,11.855,"ANS 11 " 10 | 6084.3666,12.219,11.954,11.821,12.051,"ANS 157" 11 | 6086.3389,12.234,12.079,,12.032,"ANS 11 " 12 | 6088.3801,12.347,12.066,11.878,,"ANS 157" 13 | 6090.3679,12.492,12.141,11.994,12.232,"ANS 157" 14 | 6093.3861,12.787,12.300,12.179,12.189,"ANS 11 " 15 | 6094.3868,12.860,12.327,12.170,12.576,"ANS 11 " 16 | 6094.4045,12.826,12.319,,,"ANS 157" 17 | 6095.3845,12.921,12.371,,12.578,"ANS 11 " 18 | 6096.3720,13.046,12.454,12.322,12.522,"ANS 157" 19 | 6097.3697,13.127,12.533,12.405,12.418,"ANS 157" 20 | 6098.3503,13.261,12.524,,12.740,"ANS 11 " 21 | 6100.3713,13.467,12.640,12.541,12.498,"ANS 157" 22 | 6101.3818,13.583,12.745,,12.460,"ANS 11 " 23 | 6105.3752,13.939,12.854,12.554,12.374,"ANS 157" 24 | 6113.3878,14.577,13.258,,,"ANS 157" 25 | 6116.3744,14.637,13.424,,,"ANS 157" 26 | -------------------------------------------------------------------------------- /CoreConceptsPy/Astronomic_Spaces/case_examples/events/events_cases.py: -------------------------------------------------------------------------------- 1 | from events import AstroEvent 2 | from events import AstroTime 3 | from objects import AstroObject 4 | from networks import AstroNetwork 5 | from fields import AstroField 6 | from locations import Distance 7 | 8 | """ 9 | Case study: The impacts of Supernova 2011fe 10 | Sources: 11 | http://cdsarc.u-strasbg.fr/viz-bin/Cat?J/other/NewA/20.30 12 | https://arxiv.org/pdf/1612.02097.pdf 13 | https://arxiv.org/pdf/1705.04204.pdf 14 | 15 | :author: Fenja Kollasch 16 | :date: 06/02/2017 17 | """ 18 | 19 | 20 | class SnIa(AstroEvent): 21 | def __init__(self, id, start, progenitor, radio_emission): 22 | # Fitted by Zheng et al, 2017 23 | self.progenitor = progenitor 24 | self.lightcurve = lambda t: (t.value() / 19.5) ** 2.1 * (1 + (t.value() / 19.5) ** (1.57 * (2.1 + 2.19))) ** ( 25 | -2 / 1.57) 26 | 27 | participants = {progenitor: self.__change_progenitor, radio_emission: self.__change_radio_emission} 28 | 29 | super(SnIa, self).__init__(id, participants, start=start) 30 | 31 | def __change_progenitor(self, p, t): 32 | lum = self.lightcurve(t - self.start) 33 | p.set_property('visual_magnitude', lum) 34 | return p 35 | 36 | def __change_radio_emission(self, e, time): 37 | t = (time.value() - self.start.value()) * 86400 38 | field = e.local(lambda l: l * (1 / t) ** -3.42 * t ** ((2.86 * 13 - 25.3) / 13.0)) 39 | field.domain = Distance((t ** (10 / 13) * 10), self.progenitor.bounds()) 40 | return field 41 | 42 | # The white dwarf double star system that caused the supernova 43 | white_dwarf_system = AstroNetwork("2011fe Double Star System", lon=210.75, lat=54.16, bounding='ccs', reference='icrs') 44 | dwarf = AstroObject("2011fe Dwarf") 45 | companion = AstroObject("2011fe Companion") 46 | white_dwarf_system.addNode(dwarf) 47 | white_dwarf_system.addNode(companion) 48 | white_dwarf_system.addEdge(companion, dwarf, relation="feeding") 49 | 50 | 51 | # Radio emission field, dependent on the distance to the progenitor 52 | radio_emission = AstroField(lambda r: (10.0/13.0)**3.86 * 10**11 * 53 | (0.16 * (10.0/13.0) * (r.distance*3.086*10**13)/(5*10**4))**-3.42 54 | * 0.1**1.07 * (3.00*10**9) * 0.32**((1.93*13-8.43)/13), 55 | domain=Distance(1, white_dwarf_system.bounds())) 56 | 57 | 58 | # The supernova event 59 | sn = SnIa("SN 2011fe", AstroTime(55796.687, 2400000, 'jd'), white_dwarf_system, radio_emission) 60 | 61 | # Now ask questions about the event and its participants 62 | print("Brightness at October 31, 2011: {0}".format( 63 | sn.status(white_dwarf_system, AstroTime("2011-10-31 23:00:00")).property('visual_magnitude'))) 64 | print("Radio emission at a radius of 0.5pc at October 31, 2011: {0}".format( 65 | sn.status(radio_emission, AstroTime("2011-10-31 23:00:00")).value_at(Distance(0.5, white_dwarf_system.bounds())))) 66 | 67 | -------------------------------------------------------------------------------- /CoreConceptsPy/Astronomic_Spaces/case_examples/fields/cases_field.py: -------------------------------------------------------------------------------- 1 | """ 2 | Some cases for the core concept 'field' in astronomy. 3 | Data based on the observations and calculations of Brand and Blitz about the velocity field of the galaxy 4 | http://cdsarc.u-strasbg.fr/viz-bin/Cat?J/A%2bA/275/67 5 | :author: Fenja Kollasch, 06/2017 6 | """ 7 | import csv 8 | import math as m 9 | from fields import AstroField 10 | from locations import Distance 11 | 12 | # Parse data file 13 | velo_map = dict() 14 | 15 | with open("velocity_field.csv") as file: 16 | reader = csv.DictReader(file) 17 | for row in reader: 18 | galactic_distance = (float(row['dist'])**2 * m.cos(float(row['glat']))**2 + 8.5**2 - 2*8.5 * float(row['dist']) 19 | * m.cos(float(row['glat'])) * m.cos(float(row['glon'])))**0.5 20 | pos = Distance(galactic_distance, 'galactic center', lon=float(row['glon']), lat=float(row['glat'])) 21 | velo_map[pos] = float(row['Vlsr']) 22 | 23 | r_sun = 8.5 24 | theta_sun = 220 25 | 26 | 27 | # Interpolation based on the Chi Square fitting routine 28 | velocity_galaxy = AstroField(lambda d, p: ((1.00767 * (((p.distance/r_sun)**0.0394 + 0.00712) * theta_sun) 29 | * r_sun)/p.distance - theta_sun) * m.sin(p.lon) * m.cos(p.lat), 30 | velo_map.keys(), data=velo_map) 31 | # Mask problem areas 32 | velocity_galaxy.mask(lambda x: (30 < x.lon < 150 or 210 < x.lon < 330) and x.distance >= 1) 33 | 34 | # Calculate circular velocities for every cell position 35 | rotation_curve = velocity_galaxy.local(lambda v, p: (v/(m.sin(p.lon)*m.cos(p.lat)) + theta_sun) * p.distance/r_sun) 36 | 37 | print("The rotation velocity in a distance of 20kpc from the galactic center is: {0}.".format( 38 | rotation_curve.value_at(Distance(20, 'galactic center', lon=90, lat=90)))) 39 | 40 | print(rotation_curve) 41 | -------------------------------------------------------------------------------- /CoreConceptsPy/Astronomic_Spaces/case_examples/locations_objects/cases_location.py: -------------------------------------------------------------------------------- 1 | """ 2 | In this file, we present a number of possible spatial questions in regard of locations 3 | No serious data yet (copied from Wikipedia) 4 | 5 | :author: Fenja Kollasch 6 | """ 7 | import sys 8 | sys.path.append('../') 9 | import locations as l 10 | 11 | # Case 1: Where is Bellatrix seen from Sirius? Where is Bellatrix seen from Sirius in regard of the earth? 12 | print("Where is Bellatrix seen from Sirius? Where is Bellatrix seen from Sirius in regard of the earth?") 13 | bellatrix = l.SphericalCoord(lon=81.2828, lat=6.3497, frame='icrs', distance_module=(1.64-(-2.87))) 14 | sirius = l.SphericalCoord(lon=101.2876, lat=-16.7161, frame='icrs', distance_module=(-1.47-1.42)) 15 | sirius_cart = l.translate(sirius, 'cartesian') 16 | print("Bellatrix is {0} away from earth".format(bellatrix.distance())) 17 | print("Bellatrix is {0} from Sirius away" 18 | .format(bellatrix.distance(sirius))) 19 | 20 | print("Bellatrix is {0} from Sirius away, obtained from the earth" 21 | .format(bellatrix.distance(sirius_cart))) 22 | 23 | print() 24 | 25 | # Case 2: Can I see Vega from Santa Barbara this year at July 04, 11pm? Where? 26 | print("Case 2: Can I see Vega from Santa Barbara this year at July 04, 11pm? Where?") 27 | santa_barbara = [34.4208, 119.6982, 0] 28 | vega = l.SphericalCoord(lon=279, lat=38.47, frame='icrs', distance_module=(0.026-0.582), 29 | observer=santa_barbara, time='2017-7-04 23:00:00') 30 | vega.change_frame('altaz') 31 | if vega.lon < 0: 32 | print("Vega is not visible from Santa Barbara this year at July 04, 11pm") 33 | else: 34 | print("Vega is visible at {0.lon}, {0.lat} from Santa Barbara this year at July 04, 11pm".format(vega)) 35 | 36 | -------------------------------------------------------------------------------- /CoreConceptsPy/Astronomic_Spaces/case_examples/locations_objects/cases_object.py: -------------------------------------------------------------------------------- 1 | """ 2 | Some example cases for spatial questions in astronomy with objects 3 | Data taken from the Vizier Sky catalogues 4 | :author: Fenja Kollasch, 06/2017 5 | """ 6 | 7 | import csv 8 | from objects import AstroObject 9 | from objects import AstroObjectSet 10 | 11 | 12 | # Model a cepheid as a specific AstroObject: 13 | class Cepheid(AstroObject): 14 | 15 | def _calc_app_mag(self): 16 | if "F475W" not in self._data and "F814W" not in self._data: 17 | raise ValueError("Your data contains not enough bands for a proper estimation of the apparent magnitude.") 18 | 19 | # Wesenheit magnitude 20 | return float(self._data["F814W"]) - 0.879 * (float(self._data["F475W"]) - float(self._data["F814W"])) 21 | 22 | def _calc_distance_module(self): 23 | if "F160W" in self._data and "F110W" in self._data: 24 | m_inf = float(self._data["F160W"]) - 1.54 * (float(self._data["F110W"]) - float(self._data["F160W"])) 25 | return (super(Cepheid, self)._calc_distance_module() + (m_inf - self.property('abs_mag'))) / 2 26 | return super(Cepheid, self)._calc_distance_module() 27 | 28 | # Read in catalogue 29 | cepheids = AstroObjectSet() 30 | with open("wk_cepheids.csv") as file: 31 | reader = csv.DictReader(file) 32 | id = 1 33 | for row in reader: 34 | obj = Cepheid("WKCeph " + str(id), **row) 35 | cepheids.add(obj) 36 | id += 1 37 | 38 | # Case 1: Which cepheid around M31 is the brightest (apparent and absolute)? 39 | print("Case 1: Which cepheid around M31 is the brightest (apparent and absolute)?") 40 | brightest_app = None 41 | brightest_abs = None 42 | for cepheid in cepheids: 43 | if brightest_app is None or brightest_app.property('app_mag') > cepheid.property('app_mag'): 44 | brightest_app = cepheid 45 | if brightest_abs is None or brightest_abs.property('abs_mag') > cepheid.property('abs_mag'): 46 | brightest_abs = cepheid 47 | 48 | print("{0.id} is the apparently brightest cepheid.".format(brightest_app)) 49 | print("{0.id} is the absolutely brightest cepheid.".format(brightest_abs)) 50 | 51 | # Case 2: How far are the cepheids away from earth (in average)? 52 | print("Case 2: How far are the cepheids away from earth (in average)?") 53 | dis_m31 = sum(c.relation("earth", "distance") for c in cepheids) / cepheids.len() 54 | print("The cepheids are averagely {0} parsecs away. This is also estimately the distance to M31 ;)".format(dis_m31)) 55 | -------------------------------------------------------------------------------- /CoreConceptsPy/Astronomic_Spaces/events.py: -------------------------------------------------------------------------------- 1 | """ 2 | An implementation of the core concept event for astronomic spaces 3 | :author: Fenja Kollasch, 06/2017 4 | """ 5 | 6 | from coreconcepts import CcEvent 7 | from astropy.time import Time 8 | 9 | 10 | class AstroTime(object): 11 | """ 12 | A simple wrapper for AstroPy's Time class. 13 | Accepts any format as Input, but returns it as ISO 14 | """ 15 | def __init__(self, value, add_value=None, form='iso'): 16 | self.__time = Time(value, add_value, format=form) 17 | 18 | @property 19 | def time(self): 20 | return self.__time.iso 21 | 22 | def __sub__(self, other): 23 | return AstroTime(self.__time - other.__time, form=other.__time.format) 24 | 25 | def value(self): 26 | return float(self.__time.jd) 27 | 28 | 29 | class AstroEvent(CcEvent): 30 | 31 | def __init__(self, identity, participants=None, **props): 32 | """ 33 | A happening with a fix timestamp that is not always know 34 | Other components can participate in this event 35 | :param identity: The identity of this event 36 | :param participants: The participants mapped to the functions changing them 37 | :param props: Properties of this event 38 | """ 39 | self.id = identity 40 | self.start = props.pop('start', None) 41 | self.end = props.pop('end', None) 42 | self.participants = participants 43 | 44 | self.__props = props 45 | 46 | def when(self): 47 | return self.start 48 | 49 | def within(self): 50 | return self.end - self.start 51 | 52 | def during(self, event): 53 | return event.start <= self.start and self.end <= event.end 54 | 55 | def before(self, event): 56 | return self.end < event.start 57 | 58 | def after(self, event): 59 | return event.end < self.start 60 | 61 | def overlap(self, event): 62 | return self.end < event.start or event.end < self.start 63 | 64 | def property(self, prop): 65 | return self.__props[prop] 66 | 67 | def participant(self, participant): 68 | for p in self.participants.keys(): 69 | if p == participant: 70 | return p 71 | raise EventError("{0} is not participating in this event.".format(participant)) 72 | 73 | def status(self, participant, timestamp): 74 | """ 75 | Returns the status of a participant during this event at a specific time 76 | :param participant: The participating component 77 | :param timestamp: The timestamp 78 | :return: The component with its properties at this time 79 | """ 80 | try: 81 | return self.participants[participant](participant, timestamp) 82 | except KeyError: 83 | raise EventError("The component {0} is not participating in the event.".format(participant)) 84 | 85 | 86 | class EventError(Exception): 87 | def __init__(self, message): 88 | super(EventError, self).__init__(message) 89 | -------------------------------------------------------------------------------- /CoreConceptsPy/Astronomic_Spaces/tests/networktest.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests for network implementation 3 | :author: Fenja Kollasch, 06/2017 4 | """ 5 | import sys 6 | sys.path.append('../') 7 | import networks as n 8 | import objects as o 9 | 10 | # Model the big dipper as unordered graph... because you can observe a constellation only from left to right... or so 11 | big_dipper = n.AstroNetwork("big dipper") 12 | 13 | alkaid = o.AstroObject("alkaid", lon=206.27, lat=49.18, bounding='ccs', reference='icrs') 14 | mizar = o.AstroObject("mizar", lon=200.75, lat=54.55, bounding='ccs', reference='icrs') 15 | alioth = o.AstroObject("alioth", lon=193.5, lat=55.57, bounding='ccs', reference='icrs') 16 | megrez = o.AstroObject("megrez", lon=183.75, lat=57.01, bounding='ccs', reference='icrs') 17 | phecda = o.AstroObject("phecda", lon=178.25, lat=53.41, bounding='ccs', reference='icrs') 18 | merak = o.AstroObject("merak", lon=165.25, lat=56.22, bounding='ccs', reference='icrs') 19 | dubhe = o.AstroObject("dubhe", lon=165.75, lat=61.41, bounding='ccs', reference='icrs') 20 | 21 | big_dipper.addNode(alkaid) 22 | big_dipper.addNode(mizar) 23 | big_dipper.addNode(alioth) 24 | big_dipper.addNode(megrez) 25 | big_dipper.addNode(phecda) 26 | big_dipper.addNode(merak) 27 | big_dipper.addNode(dubhe) 28 | 29 | # Totally absurd color object... 30 | big_dipper.addEdge(alkaid, mizar, distance=alkaid.relation(mizar, 'distance'), color="blue") 31 | big_dipper.addEdge(mizar, alioth, distance=mizar.relation(alioth, 'distance'), color="blue") 32 | big_dipper.addEdge(alioth, megrez, distance=alioth.relation(megrez, 'distance'), color="blue") 33 | big_dipper.addEdge(megrez, dubhe, distance=megrez.relation(dubhe, 'distance'), color="red") 34 | big_dipper.addEdge(megrez, phecda, distance=megrez.relation(phecda, 'distance'), color="blue") 35 | big_dipper.addEdge(phecda, merak, distance=phecda.relation(merak, 'distance'), color="blue") 36 | big_dipper.addEdge(merak, dubhe, distance=merak.relation(dubhe, 'distance'), color="blue") 37 | 38 | print("Path from Alkaid to Dubhe: {0}".format(alkaid.relation(mizar, 'distance') + 39 | mizar.relation(alioth, 'distance') + 40 | alioth.relation(megrez, 'distance') + 41 | megrez.relation(dubhe, 'distance'))) 42 | 43 | print(big_dipper.shortestPath(alkaid, dubhe, weight=('distance', 0))) 44 | print(big_dipper.shortestPath(alkaid, dubhe, weight=('distance', 0), color=('color', 'blue'))) 45 | 46 | print("first breadth from megrez (2):") 47 | for s in big_dipper.breadthFirst(megrez, 2): 48 | print(str(s)) 49 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Core Concepts Python library 3 | # 4 | # ====== VARIABLES ====== 5 | 6 | # ====== TARGETS ====== 7 | all: 8 | @echo "Select an option."; 9 | @cat Makefile; 10 | @echo "\n"; 11 | 12 | clean: 13 | @rm -rf *.pyc **/*.pyc tmp; 14 | @mkdir tmp; 15 | 16 | test-events: clean 17 | python -m unittest discover -s 'test' -p 'events_test.py' -t '..'; 18 | 19 | test-fields: clean 20 | python -m unittest discover -s 'test' -p 'fields_test.py' -t '..'; 21 | 22 | test-locations: clean 23 | @echo "No examples and no tests for locations yet." 24 | 25 | test-networks: clean 26 | python -m unittest discover -s 'test' -p 'networks_test.py' -t '..'; 27 | 28 | test-objects: clean 29 | python -m unittest discover -s 'test' -p 'objects_test.py' -t '..'; 30 | 31 | test-all: clean 32 | python -m unittest discover -s 'test' -p '*_test.py' -t '..'; 33 | 34 | example-events: clean 35 | python examples/events/example_1.py 36 | python examples/events/example_2.py 37 | python examples/events/example_3.py 38 | python examples/events/earthquake/output_use_case.py 39 | python examples/events/earthquake/input_use_case.py 40 | 41 | example-fields: clean 42 | @echo "No examples for fields yet. Have a look at the tests." 43 | 44 | example-locations: clean 45 | @echo "No examples and no tests for locations yet." 46 | 47 | example-networks: clean 48 | python examples/networks/karate.py 49 | python examples/networks/synthetic_weighted_network.py 50 | python examples/networks/ucsb.py 51 | 52 | example-objects: clean 53 | @echo "No examples for objects yet. Have a look at the tests." 54 | 55 | example-all: example-events example-fields example-locations example-networks example-objects 56 | 57 | install-dependencies: 58 | # for Linux/Mac 59 | sudo pip install networkx; 60 | @echo "Make sure, that you have installed GDAL and NumPy!" 61 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Python (GDAL) 2 | ============================================= 3 | 4 | Abstract: A Python implementation of the core concepts leveraging GDAL processing. 5 | 6 | The implementation is divided into abstract definitions (`coreconcepts.py`), 7 | implementation of one core concept per file (`events.py`, `fields.py`, `locations.py`, `networks.py` and `objects.py`) 8 | and unit tests (`test/`) and additionally into examples (`examples/`) to showcase the different possibilities of the core concepts. 9 | 10 | See the [Readme](../../README.md) in the parent directory for general information about the Core Concepts. 11 | 12 | Right now the implementation is in a proof of concept state and should not be considered stable for a production environment. 13 | 14 | Contents 15 | ---------------------- 16 | 17 | - `coreconcepts.py`: Abstract concepts. 18 | - `events.py`: Implementations of events. 19 | - `examples/`: Usage examples of implementations. 20 | - `fields.py`: Implementations of fields. 21 | - `locations.py`: Implementations of locations. 22 | - `Makefile`: Common commands for unix platforms. 23 | - `makefile.py`: Common commands for non-unix platforms. 24 | - `networks.py`: Implementations of networks. 25 | - `objects.py`: Implementations of objects. 26 | - `test/`: Unit tests. 27 | - `utils.py`: Utilities. 28 | - `RdfReader.py`: Abstract Reader to turn RDF into python objects. 29 | - `RdfWriter.py`: Abstract Writer to turn RDF into python objects. 30 | 31 | How to test the code and run the examples 32 | ----------------------------------------- 33 | 34 | ### Unix/Linux platforms 35 | To run the Unit Tests execute: `make test-all` 36 | 37 | To run the examples execute: `make example-all` 38 | 39 | ### Platforms without `make` (like Windows) [WIP] 40 | To run the Unit Tests execute: `python makefile.py test-all` 41 | 42 | To run the Examples execute: `python makefile.py example-all` 43 | 44 | How to test the code and run the examples 45 | ----------------------------------------- 46 | 47 | ### Unix/Linux platforms 48 | To run the Unit Tests execute: `make test-all` 49 | 50 | To run the examples execute: `make example-all` 51 | 52 | Dependencies 53 | ---------------------- 54 | - [GDAL] (http://www.gdal.org) (Version: latest*) 55 | - [NumPy] (http://www.numpy.org) (Version: latest*) 56 | - [NetworkX] (https://networkx.github.io/) (Version: 1.9.1) 57 | 58 | \* Most recent stable release 59 | 60 | ### Unix/Linux platforms 61 | To install the dependencies execute: `make install-dependencies` 62 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/RdfReader.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Abstract: Turns RDF into python objects. 4 | Using RDFlib it parses a RDF file and turns each RDF object in that file to a python object. 5 | The python objects will be returned as an array. 6 | """ 7 | __author__ = "Marc Tim Thiemann" 8 | __copyright__ = "Copyright 2015" 9 | __credits__ = ["Marc Tim Thiemann"] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "" 13 | __email__ = "" 14 | __date__ = "February 2015" 15 | __status__ = "Development" 16 | 17 | from rdflib import * 18 | import json 19 | 20 | class RdfReader(object): 21 | 22 | def __init__(self, bindings = None): 23 | """ 24 | Initialize Graph and setup namespaces 25 | @param bindings The path to a json configuration file. 26 | Each prefix/namespace binding is stored as an object in an array named "bindings". 27 | Each object has a name/value pair for the prefix and the namespace. 28 | The name for the prefix is "prefix" and the name for the namespace is "namespace". 29 | """ 30 | self.g = Graph() 31 | 32 | self.setNamespaces(bindings) 33 | 34 | def read(self, destination, format): 35 | """ 36 | Parse RDF file into rdflib graph 37 | @param destination The destination of the file that contains the RDF data 38 | @param format The input format. Supported formats: ‘xml’, ‘n3’, ‘turtle’, ‘nt’, ‘pretty-xml’, trix’ 39 | """ 40 | 41 | self.g.parse(destination, format=format) 42 | 43 | return self.getObjs() 44 | 45 | def getObjs(self): 46 | """ 47 | Turns RDF to python objects 48 | @return An array of python objects 49 | """ 50 | 51 | raise NotImplementedError('getObjs') 52 | 53 | def setNamespaces(self, bindings): 54 | """ 55 | Sets up the namespaces 56 | @param bindings The path to a json configuration file. The json file should have an array called "bindings". 57 | Each object in this array should have an attribute called "prefix" for the prefix and an attribute called "namespace" for the namespace uri. 58 | """ 59 | 60 | json_data = open(bindings).read() 61 | data = json.loads(json_data) 62 | 63 | for obj in data['bindings']: 64 | setattr(self, obj['prefix'], Namespace(obj['namespace'])) 65 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/RdfWriter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Abstract: An abstract class to turn an array of python objects into RDF. 4 | Gets an Array of python objects and turns them to RDF using RDFlib. 5 | The RDF can either be outputted or written to a file. 6 | """ 7 | __author__ = "Marc Tim Thiemann" 8 | __copyright__ = "Copyright 2015" 9 | __credits__ = ["Marc Tim Thiemann"] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "" 13 | __email__ = "" 14 | __date__ = "February 2015" 15 | __status__ = "Development" 16 | 17 | from rdflib import * 18 | import json 19 | 20 | class RdfWriter(object): 21 | 22 | def __init__(self, bindings = None): 23 | """ 24 | Initialize Graph and setup namespaces 25 | @param bindings The path to a json configuration file. 26 | Each prefix/namespace binding is stored as an object in an array named "bindings". 27 | Each object has a name/value pair for the prefix and the namespace. 28 | The name for the prefix is "prefix" and the name for the namespace is "namespace". 29 | """ 30 | self.g = Graph() 31 | 32 | if bindings is not None: 33 | self.bindNamespaces(bindings) 34 | 35 | def add(self, uri, obj): 36 | """ 37 | Add a single object to the graph 38 | @param uri The uri of that object 39 | @param obj The object that should be added 40 | """ 41 | 42 | raise NotImplementedError("add") 43 | 44 | def serialize(self, format = 'xml', destination = None): 45 | """ 46 | Serializes the graph into the specified RDF format and outputs it or writes it to file 47 | @param format The output format. Supported formats: ‘xml’, ‘n3’, ‘turtle’, ‘nt’, ‘pretty-xml’, trix’ 48 | @param destination The destination of the output file 49 | """ 50 | if destination is None: 51 | print self.g.serialize(format=format) 52 | else: 53 | self.g.serialize(destination = destination + '.' + self.getExtension(format), format=format) 54 | 55 | def getExtension(self, format): 56 | """ 57 | Get the file extension for a given format 58 | @param format The format 59 | """ 60 | if format == "xml": 61 | return "rdf" 62 | elif format == "turtle": 63 | return "ttl" 64 | elif format == "pretty-xml": 65 | return "xml" 66 | else: 67 | return format 68 | 69 | def bindNamespaces(self, bindings): 70 | """ 71 | Binds namespaces to the graph 72 | @param bindings The path to a json configuration file. The json file should have an array called "bindings". 73 | Each object in this array should have an attribute called "prefix" for the prefix and an attribute called "namespace" for the namespace uri. 74 | """ 75 | 76 | json_data = open(bindings).read() 77 | data = json.loads(json_data) 78 | 79 | for obj in data['bindings']: 80 | setattr(self, obj['prefix'], Namespace(obj['namespace'])) 81 | self.g.bind(obj['prefix'], getattr(self, obj['prefix'])) 82 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/CoreConceptsPy/GdalPy/__init__.py -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Python usage examples 2 | ============================================================ 3 | 4 | Abstract: Python usage examples of core concept python implementations 5 | 6 | Contents 7 | ---------------------- 8 | 9 | * `events/`: Usage examples of the python event implementation. 10 | * `fields/`: Usage examples of the python field implementation. 11 | * `locations/`: Usage examples of the python location implementation. 12 | * `networks/`: Usage examples of the python network implementation. 13 | * `objects/`: Usage examples of the python object implementation. 14 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/CoreConceptsPy/GdalPy/examples/__init__.py -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/china_lights/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - China Lights 2 | ============================================================ 3 | 4 | Abstract: TODO 5 | 6 | Contents 7 | ---------------------- 8 | 9 | TODO -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/china_lights/china_lights-lowe_2014/China_example_Lowe_text_2014.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/CoreConceptsPy/GdalPy/examples/china_lights/china_lights-lowe_2014/China_example_Lowe_text_2014.pdf -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/china_lights/china_lights-lowe_2014/China_example_figure.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/CoreConceptsPy/GdalPy/examples/china_lights/china_lights-lowe_2014/China_example_figure.pdf -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/china_lights/china_lights_cc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | """ 6 | Abstract: Implementation of China Lights case study using Python Core Concepts 7 | 8 | @todo: check test/fields_test.py for field logic 9 | @todo: check object logic in test/objects_test.py 10 | @todo: use GeoTiffField for fields. use ArcShpObject for objects, and build_object_set for object sets. 11 | """ 12 | 13 | __author__ = "" 14 | __copyright__ = "" 15 | __credits__ = ["", ""] 16 | __license__ = "" 17 | __version__ = "" 18 | __maintainer__ = "" 19 | __email__ = "" 20 | __date__ = "" 21 | __status__ = "" 22 | 23 | import sys 24 | import os 25 | import unittest 26 | import numpy as np 27 | import random 28 | 29 | sys.path = [ '.', '..', '../..' ] + sys.path 30 | from utils import _init_log, float_eq 31 | from fields import * 32 | 33 | 34 | def load_data(): 35 | print "loadData..." 36 | # PSEUDO CODE 37 | # china = new object("China.shp") 38 | # gas_flares = new object_set("Flares_China_1.shp") 39 | # roads = new object_set("a2010_final_proj.shp") 40 | # lights_101994 = new field("F101994", china, inside) 41 | # lights_121994 = new field("F121994", china, inside) 42 | 43 | # PYTHON CODE 44 | field_path = 'data/some_raster.tiff' 45 | objectset_path = 'data/someshapefile.shp' 46 | # TODO: load data here using the right classes 47 | # use addDomain on the fields 48 | 49 | light_1994a_field = GeoTiffField( field_path ) 50 | light_1994b_field = GeoTiffField( field_path2 ) 51 | flare_objset = ArcShpObjectSet( flare_path ) 52 | # etc 53 | return light_1994a_field, light_1994b_field, flare_objset 54 | 55 | def field_avg( values ): 56 | # TODO: implement field average function on n values 57 | return None 58 | 59 | def compute_luminosity( light_1994a_field, light_1994b_field, flare_objset ): 60 | print "Compute luminosity" 61 | # PSEUDO CODE 62 | # # What is the luminosity in year 1994 in China, 63 | # # excluding gas flares? 64 | # luminosity_1994 = local(lights_101994, lights_121994, average) 65 | # luminosity_excluding_flares = set_domain(luminosity_1994, gas_flares, outside) 66 | # # What is the luminosity within 0.5 degrees from roads? 67 | # roads_buffered = buffer(roads, 0.5) luminosity_around_roads = set_domain(luminosity_1994, roads_buffered, inside) 68 | # # What is the mean luminosity in a 0.1 by 0.1 degree area? 69 | # final_result = coarsen(luminosity_around_roads, 0.1, 0.1) 70 | 71 | # PYTHON CODE 72 | light_1994_field = light_1994a_field.local( [light_1994b_field], field_avg ) 73 | # TODO 74 | # buffer to be called on ArcShpObjectSet 75 | # coarsen 76 | 77 | def main(): 78 | print 'Running China Lights case study' 79 | light_1992_field, light_1994_field, flare_objset = load_data() 80 | luminosity_field = compute_luminosity( light_1992_field, light_1994_field, flare_objset ) 81 | print 'OK' 82 | 83 | if __name__ == '__main__': 84 | main() 85 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/events/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - PyEvent use cases 2 | ========================================================= 3 | 4 | Abstract: PyEvent use cases based on real event data. 5 | 6 | Contents 7 | ---------------------- 8 | 9 | * `example_1.py`: PyEvent use cases based on global earthquake events of December 2014. 10 | * `example_2.py`: PyEvent use cases based on US weather data from 1 January 2015. 11 | * `example_3.py`: PyEvent use cases based on UCSB Winter quarter 2014 course data. 12 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/events/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/CoreConceptsPy/GdalPy/examples/events/__init__.py -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/events/earthquake/EarthquakeRdfReader.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Abstract: Turns earthquake objects from RDF into python objects. 4 | Using RDFlib it parses a RDF file and turns each Earthquake RDF object in that file to a Python Earthquake objects. 5 | The Python Earthquake objects will be returned as an array. 6 | 7 | This class inherits from RdfReader! 8 | """ 9 | __author__ = "Marc Tim Thiemann" 10 | __copyright__ = "Copyright 2015" 11 | __credits__ = ["Marc Tim Thiemann"] 12 | __license__ = "" 13 | __version__ = "0.1" 14 | __maintainer__ = "" 15 | __email__ = "" 16 | __date__ = "February 2015" 17 | __status__ = "Development" 18 | 19 | from earthquake import * 20 | from RdfReader import * 21 | 22 | class EarthquakeRdfReader(RdfReader): 23 | 24 | def getObjs(self): 25 | """ 26 | Turns RDF to earthquake objects 27 | @return An array of earthquake objects 28 | """ 29 | 30 | earthquakes = [] 31 | 32 | for subject, predicate, obj in self.g.triples( (None, RDF.type, self.eq.Earthquake) ): 33 | properties = { 34 | 'latitude': self.g.value(subject, self.geo.lat), 35 | 'longitude': self.g.value(subject, self.geo.long), 36 | 'place': self.g.value(subject, self.lode.atPlace), 37 | 'atTime': self.g.value(subject, self.lode.atTime), 38 | 'mag': self.g.value(subject, self.qudt.vectorMagnitude) 39 | } 40 | 41 | earthquakes.append(Earthquake(properties)) 42 | 43 | return earthquakes 44 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/events/earthquake/EarthquakeRdfReader2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Abstract: Turns earthquake objects from RDF into python objects. 4 | Using RDFlib it parses a RDF file and turns each Earthquake RDF object in that file to a Python Earthquake objects. 5 | The Python Earthquake objects will be returned as an array. 6 | 7 | This class does not inherit from RdfReader! 8 | """ 9 | __author__ = "Marc Tim Thiemann" 10 | __copyright__ = "Copyright 2015" 11 | __credits__ = ["Marc Tim Thiemann"] 12 | __license__ = "" 13 | __version__ = "0.1" 14 | __maintainer__ = "" 15 | __email__ = "" 16 | __date__ = "February 2015" 17 | __status__ = "Development" 18 | 19 | from rdflib import Graph, Namespace, RDF 20 | from earthquake import * 21 | import json 22 | 23 | class EarthquakeRdfReader2(): 24 | 25 | def __init__(self, bindings = None): 26 | """ 27 | Initialize Graph and setup namespaces 28 | @param bindings The path to a json configuration file. 29 | """ 30 | self.g = Graph() 31 | 32 | self.setNamespaces(bindings) 33 | 34 | def read(self, destination, format): 35 | """ 36 | Read RDF file and turn it into core concept objects 37 | @param destination The destination of the file that contains the RDF data 38 | @param format The input format. Supported formats: ‘xml’, ‘n3’, ‘turtle’, ‘nt’, ‘pretty-xml’, trix’ 39 | """ 40 | 41 | self.g.parse(destination, format=format) 42 | 43 | earthquakes = [] 44 | 45 | for subject, predicate, obj in self.g.triples( (None, RDF.type, self.eq.Earthquake) ): 46 | earthquakes.append(self.parse(subject)) 47 | 48 | return earthquakes 49 | 50 | def parse(self, subject): 51 | """ 52 | Create python Earthquake object for the passed RDF subject 53 | @param subject The subject that needs to be turned into a python earthquake object 54 | """ 55 | 56 | properties = { 57 | 'latitude': self.g.value(subject, self.geo.lat), 58 | 'longitude': self.g.value(subject, self.geo.long), 59 | 'place': self.g.value(subject, self.lode.atPlace), 60 | 'atTime': self.g.value(subject, self.lode.atTime), 61 | 'mag': self.g.value(subject, self.qudt.vectorMagnitude), 62 | } 63 | 64 | return Earthquake(properties) 65 | 66 | def setNamespaces(self, bindings): 67 | """ 68 | Sets up the namespaces 69 | @param bindings The path to a json configuration file. The json file should have an array called "bindings". 70 | Each object in this array should have an attribute called "prefix" for the prefix and an attribute called "namespace" for the namespace uri. 71 | """ 72 | 73 | json_data = open(bindings).read() 74 | data = json.loads(json_data) 75 | 76 | for obj in data['bindings']: 77 | setattr(self, obj['prefix'], Namespace(obj['namespace'])) 78 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/events/earthquake/EarthquakeRdfWriter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Abstract: Creates RDF for earthquake objects. 4 | Gets an Array of Python Earthquake objects and turns them to RDF using RDFlib. 5 | The RDF can either be outputted or written to a file. 6 | 7 | This class inherits from RdfWriter! 8 | """ 9 | __author__ = "Marc Tim Thiemann" 10 | __copyright__ = "Copyright 2015" 11 | __credits__ = ["Marc Tim Thiemann"] 12 | __license__ = "" 13 | __version__ = "0.1" 14 | __maintainer__ = "" 15 | __email__ = "" 16 | __date__ = "February 2015" 17 | __status__ = "Development" 18 | 19 | import sys 20 | sys.path.insert(1,'../../../../CoreConceptsPy') 21 | from RdfWriter import * 22 | 23 | class EarthquakeRdfWriter(RdfWriter): 24 | 25 | def add(self, uri, earthquake): 26 | """ 27 | Add RDF for this earthquake to the graph. 28 | """ 29 | eq = URIRef(uri) 30 | 31 | self.g.add( (eq, RDF.type, self.eq.Earthquake) ) 32 | self.g.add( (eq, self.geo.lat, Literal(earthquake.latitude, datatype=XSD.float) ) ) 33 | self.g.add( (eq, self.geo.long, Literal(earthquake.longitude, datatype=XSD.float) ) ) 34 | self.g.add( (eq, self.qudt.vectorMagnitude, Literal(earthquake.magnitude, datatype=XSD.float) ) ) 35 | self.g.add( (eq, self.lode.atPlace, Literal(earthquake.place) ) ) 36 | self.g.add( (eq, self.lode.atTime, Literal(earthquake.atTime.isoformat(), datatype=XSD.dateTime) ) ) 37 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/events/earthquake/README.md: -------------------------------------------------------------------------------- 1 | RDF input and output with earthquake data 2 | ================================================== 3 | 4 | Abstract: Create RDF input and output with earthquake data using RDF readers and writers and an earthquake model. 5 | 6 | The Earthquake class (`earthquake.py`) works as a model for each earthquake. 7 | 8 | There are two RdfReaders that turn RDF input into earthquake python objects: 9 | (`EarthquakeRdfReader.py`) inherits from (`RdfReader.py`) which is an abstract implementation of a RdfReader. 10 | (`EarthquakeRdfReader2.py`) does not inherit from that abstract RdfReader. 11 | 12 | Similarly, there are two RdfWriters that turn Earthquake python objects into RDF: 13 | (`EarthquakeRdfWriter.py`) inherits from (`RdfWriter.py`) which is an abstract implementation of a RdfWriter. 14 | (`EarthquakeRdfWriter2.py`) does not inherit from that abstract RdfWriter. 15 | 16 | Both RdfReaders and RdfWriters are used in the (`input_use_case.py`) and (`output_use_case.py`) file, respectively. 17 | 18 | The (`bindings.json`) file works as a configuration file for RDF prefix/namespace bindings for RdfReaders and RdfWriters. 19 | 20 | RDF input and output files used for this example can be found in the folder (`CoreConceptsRdf/examples/events/earthquake/`). 21 | 22 | Contents 23 | ---------------------- 24 | 25 | * `earthquake.py`: Earthquake class. 26 | * `EarthquakeRdfReader.py`: Reads Earthquake RDF and turns it into Earthquake python objects (inherits from RdfReader). 27 | * `EarthquakeRdfReader2.py`: Reads Earthquake RDF and turns it into Earthquake python objects (does not inherit from RdfReader). 28 | * `EarthquakeRdfWriter.py`: Writes Earthquake python objects to RDF (inherits from RdfWriter). 29 | * `EarthquakeRdfWriter2.py`: Writes Earthquake python objects to RDF (does not inherit from RdfWriter). 30 | * `input_use_case.py`: Use case with RDF input and python output. 31 | * `output_use_case.py`: Use case with python input and RDF output. 32 | * `bindings.json`: json configuration file for RDF prefix/namespace bindings. 33 | 34 | Dependencies 35 | ---------------------- 36 | 37 | * rdflib (4.2.1) 38 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/events/earthquake/bindings.json: -------------------------------------------------------------------------------- 1 | { 2 | "bindings": [ 3 | { 4 | "prefix": "geo", 5 | "namespace": "http://www.w3.org/2003/01/geo/wgs84_pos#" 6 | }, 7 | { 8 | "prefix": "qudt", 9 | "namespace": "http://qudt.org/schema/qudt#" 10 | }, 11 | { 12 | "prefix": "lode", 13 | "namespace": "http://linkedevents.org/ontology/" 14 | }, 15 | { 16 | "prefix": "eq", 17 | "namespace": "http://myearthquakes.com/" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/events/earthquake/earthquake.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Abstract: Earthquake Event Class 4 | """ 5 | __author__ = "Marc Tim Thiemann" 6 | __copyright__ = "Copyright 2015" 7 | __credits__ = ["Marc Tim Thiemann"] 8 | __license__ = "" 9 | __version__ = "0.1" 10 | __maintainer__ = "" 11 | __email__ = "" 12 | __date__ = "Febuary 2015" 13 | __status__ = "Development" 14 | 15 | import sys 16 | sys.path.insert(1,'../../../../CoreConceptsPy') 17 | 18 | from coreconcepts import CcEvent 19 | from rdflib import Graph, BNode, Namespace, RDF, XSD, Literal, URIRef 20 | import os.path 21 | 22 | class Earthquake(CcEvent): 23 | """ This earthquake class models earthquakes. Each earthquake has a latitude, longitude, magnitude, place and a time. """ 24 | 25 | def __init__(self, properties): 26 | self.latitude = properties['latitude'] 27 | self.longitude = properties['longitude'] 28 | self.magnitude = properties['mag'] 29 | self.place = properties['place'] 30 | self.atTime = properties['atTime'] 31 | 32 | def toRDF(self, format, filename = None, eqNamespace = None): 33 | ''' 34 | @param format The output format. Supported formats: ‘xml’, ‘n3’, ‘turtle’, ‘nt’, ‘pretty-xml’, trix’ 35 | @param filename The filename for the output file 36 | ''' 37 | 38 | extension = format 39 | if format == "xml": 40 | extension = "rdf" 41 | elif format == "turtle": 42 | extension = "ttl" 43 | elif format == "pretty-xml": 44 | extension = "xml" 45 | 46 | filenameAndExtension = filename + '.' + extension 47 | 48 | g = Graph() 49 | 50 | if filename is not None and os.path.isfile(filenameAndExtension): 51 | g.parse(filenameAndExtension, format=format) 52 | 53 | # define and bind namespaces 54 | 55 | #lat, long 56 | geo = Namespace("http://www.w3.org/2003/01/geo/wgs84_pos#") 57 | g.bind('geo', geo) 58 | 59 | # magnitude 60 | dbpprop = Namespace("http://dbpedia.org/property/") 61 | g.bind('dbpprop', dbpprop) 62 | 63 | # atPlace, atTime 64 | lode = Namespace("http://linkedevents.org/ontology/") 65 | g.bind('lode', lode) 66 | 67 | # earthquake class 68 | eq = Namespace("http://myearthquakes.com/") 69 | g.bind('eq', eq) 70 | 71 | earthquake = "" 72 | if eqNamespace is not None: 73 | randomId = os.urandom(16).encode('hex') 74 | earthquake = URIRef(eqNamespace + randomId) 75 | else: 76 | earthquake = BNode() 77 | 78 | g.add( (earthquake, RDF.type, eq.Earthquake) ) 79 | g.add( (earthquake, geo.lat, Literal(self.latitude, datatype=XSD.float) ) ) 80 | g.add( (earthquake, geo.long, Literal(self.longitude, datatype=XSD.float) ) ) 81 | g.add( (earthquake, dbpprop.magnitude, Literal(self.magnitude, datatype=XSD.float) ) ) 82 | g.add( (earthquake, lode.atPlace, Literal(self.place) ) ) 83 | g.add( (earthquake, lode.atTime, Literal(self.atTime.isoformat(), datatype=XSD.dateTime) ) ) 84 | 85 | if filename is None: 86 | print g.serialize(format=format) 87 | else: 88 | g.serialize(destination = filenameAndExtension, format=format) 89 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/events/earthquake/input_use_case.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Turns earthquake RDF objects into earthquake python objects 6 | 7 | Reads RDF earthquake objects from a file that contains earthquakes of December 2014 and turns them into Earthquake python objects. 8 | Prints the first 3 Python earthquakes in the list to check if the Earthquake objects are valid. 9 | """ 10 | 11 | __author__ = "Marc Tim Thiemann" 12 | __copyright__ = "Copyright 2015" 13 | __credits__ = ["Marc Tim Thiemann"] 14 | __license__ = "" 15 | __version__ = "0.1" 16 | __maintainer__ = "" 17 | __email__ = "" 18 | __date__ = "February 2015" 19 | __status__ = "Development" 20 | 21 | import sys 22 | 23 | sys.path = [ '.', '../../..' ] + sys.path 24 | from earthquake import * 25 | from EarthquakeRdfReader import * 26 | from EarthquakeRdfReader2 import * 27 | 28 | #EarthquakeRdfReader2 does not inherit from RdfReader 29 | """ 30 | rdf = EarthquakeRdfReader2('examples/events/earthquake/bindings.json') 31 | earthquakes = rdf.read('tmp/testEarthquake.rdf', format="xml") 32 | """ 33 | 34 | rdf = EarthquakeRdfReader('examples/events/earthquake/bindings.json') 35 | earthquakes = rdf.read('tmp/testEarthquake.rdf', format="xml") 36 | 37 | for x in range(0,3): 38 | print earthquakes[x].latitude 39 | print earthquakes[x].longitude 40 | print earthquakes[x].place 41 | print earthquakes[x].atTime 42 | print earthquakes[x].magnitude 43 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/events/earthquake/output_use_case.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Turns earthquake python objects into earthquake RDF objects 6 | 7 | Reads all earthquakes from a CSV file, creates an earthquake python object for each earthquake, 8 | turns each earthquake object into RDF and writes all earthquakes as RDF into a file. 9 | 10 | Provided data: CSV file with all global earthquake events for December 2014. 11 | 12 | Output data format: RDF 13 | """ 14 | 15 | __author__ = "Marc Tim Thiemann" 16 | __copyright__ = "Copyright 2015" 17 | __credits__ = ["Marc Tim Thiemann"] 18 | __license__ = "" 19 | __version__ = "0.1" 20 | __maintainer__ = "" 21 | __email__ = "" 22 | __date__ = "February 2015" 23 | __status__ = "Development" 24 | 25 | import sys 26 | 27 | sys.path = [ '.', '../../..' ] + sys.path 28 | import dateutil.parser 29 | from datetime import * 30 | from earthquake import * 31 | from EarthquakeRdfWriter import * 32 | from EarthquakeRdfWriter2 import * 33 | import csv 34 | 35 | f = open('../data/events/earthquake_data.csv') 36 | csv_f = csv.reader(f) 37 | 38 | earthquakes = [] 39 | 40 | for row in csv_f: 41 | dt = dateutil.parser.parse(row[0], fuzzy = True, ignoretz = True) 42 | properties = { 'latitude': row[1], 43 | 'longitude': row[2], 44 | 'mag': row[4], 45 | 'place': row[13], 46 | 'atTime': dt} 47 | 48 | earthquakes.append(Earthquake(properties)) 49 | 50 | earthquakes = earthquakes[1:] 51 | 52 | # use initial EarthquakeRdfCreator that does not inherit from RdfCreator 53 | """ 54 | rdf = EarthquakeRdfCreator2('examples/events/earthquake/bindings.json') 55 | rdf.create(earthquakes, 'xml', 'tmp/testEarthquake', 'http://myearthquakes.com/earthquakes/') 56 | """ 57 | 58 | #use EarthquakeRdfCreator that inherits from RdfCreator 59 | rdf = EarthquakeRdfWriter('examples/events/earthquake/bindings.json') 60 | 61 | for e in earthquakes: 62 | earthquakeid = os.urandom(16).encode('hex') 63 | uri = "http://myearthquakes.com/earthquakes/" + earthquakeid 64 | rdf.add(uri, e) 65 | 66 | rdf.serialize('xml', 'tmp/testEarthquake') 67 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/events/example_1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Operations on earthquake data as examples for how to use the core concept 'event' 6 | 7 | Use Cases: 8 | - get all locations of earthquakes with a magnitude of 4 or higher 9 | - get all earthquakes which origin is 100 m or deeper 10 | - get all earthquakes from 12/01/2014 00:00:00 - 12/6/2014 23:59:59 11 | - get all earthquakes in Alaska 12 | 13 | Provided data: 14 | CSV file with all global earthquake events for December 2014. 15 | The fields for each earthquake are: 16 | time,latitude,longitude,depth,mag,magType,nst,gap,dmin,rms,net,id,updated,place,type 17 | """ 18 | 19 | __author__ = "Marc Tim Thiemann" 20 | __copyright__ = "Copyright 2014" 21 | __credits__ = ["Marc Tim Thiemann"] 22 | __license__ = "" 23 | __version__ = "0.1" 24 | __maintainer__ = "" 25 | __email__ = "" 26 | __date__ = "January 2015" 27 | __status__ = "Development" 28 | 29 | import sys 30 | 31 | sys.path = [ '.', '../..' ] + sys.path 32 | from utils import _init_log 33 | from events import * 34 | import dateutil.parser 35 | from datetime import * 36 | import csv 37 | 38 | log = _init_log("example-1") 39 | 40 | f = open('../data/events/earthquake_data.csv') 41 | csv_f = csv.reader(f) 42 | 43 | events = [] 44 | 45 | for row in csv_f: 46 | properties = { 'latitude': row[1], 47 | 'longitude': row[2], 48 | 'depth': row[3], 49 | 'mag': row[4], 50 | 'magType': row[5], 51 | 'nst': row[6], 52 | 'gap': row[7], 53 | 'dmin': row[8], 54 | 'rms': row[9], 55 | 'net': row[10], 56 | 'id': row[11], 57 | 'updated': row[12], 58 | 'place': row[13], 59 | 'type': row[14]} 60 | dt = dateutil.parser.parse(row[0], fuzzy = True, ignoretz = True) 61 | 62 | events.append(PyEvent((dt, dt), properties)) 63 | 64 | 65 | 66 | print 'Get all locations of earthquakes with a magnitude of 4 or higher during December 2014' 67 | 68 | locations = [] 69 | for e in events: 70 | if(e.get('mag') >= 4): 71 | locations.append((e.get('latitude'), e.get('longitude'))) 72 | 73 | 74 | 75 | print 'Get all earthquakes from 12/01/2014 00:00:00 - 12/6/2014 23:59:59' 76 | 77 | earthquakesFirstSevenDays = [] 78 | for e in events: 79 | if(e.during((datetime(2014, 12, 01, 0, 0, 0), datetime(2014, 12, 6, 23, 59, 59)))): 80 | earthquakesFirstSevenDays.append(e) 81 | 82 | 83 | print 'Get all earthquakes in Alaska during December 2014' 84 | 85 | earthquakesInAlaska = [] 86 | for e in events: 87 | if "Alaska" in e.get('place'): 88 | earthquakesInAlaska.append(e) 89 | 90 | 91 | 92 | print 'Get all earthquakes which origin is 100 m or deeper' 93 | 94 | deepEarthQuakes = [] 95 | for e in events: 96 | depth = 0.0 97 | try: 98 | depth = float(e.get('depth')) 99 | except: 100 | print 'Not a Number!' 101 | 102 | if(depth >= 100): 103 | deepEarthQuakes.append(e) 104 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/events/example_2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Operations on US weather data from 1 January 2015 as examples for how to use the core concept 'event' 6 | 7 | Use Cases: 8 | - get all weather events before 12am 9 | - when did it snow on 1 January? 10 | - get all weather events after 6 pm 11 | 12 | 13 | Provided data: 14 | text file. each row includes: datetime, latitude, longitude, weather type 15 | """ 16 | 17 | __author__ = "Marc Tim Thiemann" 18 | __copyright__ = "Copyright 2014" 19 | __credits__ = ["Marc Tim Thiemann"] 20 | __license__ = "" 21 | __version__ = "0.1" 22 | __maintainer__ = "" 23 | __email__ = "" 24 | __date__ = "January 2015" 25 | __status__ = "Development" 26 | 27 | import sys 28 | 29 | sys.path = [ '.', '../..' ] + sys.path 30 | from utils import _init_log 31 | from events import * 32 | import dateutil.parser 33 | from datetime import * 34 | 35 | log = _init_log("example-2") 36 | 37 | file = open('../data/events/weather_data.txt', 'r') 38 | 39 | events = [] 40 | 41 | for line in file: 42 | fields = line.split(' ') 43 | 44 | properties = { 45 | 'number': fields[0][:-1], 46 | 'latitude': fields[3][:-1], 47 | 'longitude': fields[4], 48 | 'type': ' '.join(fields[5:len(fields)]) 49 | } 50 | 51 | dt = dateutil.parser.parse(fields[1] + ' ' + fields[2], fuzzy = True, ignoretz = True) 52 | 53 | events.append(PyEvent((dt, dt), properties)) 54 | 55 | 56 | print 'Get all weather events before 12am' 57 | 58 | forenoonEvents = [] 59 | 60 | for e in events: 61 | if e.before(datetime(2015, 1, 1, 12, 0, 0)): 62 | forenoonEvents.append(e) 63 | 64 | 65 | print 'Get all weather events after 6pm' 66 | 67 | eveningEvents = [] 68 | 69 | for e in events: 70 | if e.after(datetime(2015, 1, 1, 18, 0, 0)): 71 | eveningEvents.append(e) 72 | 73 | 74 | print 'When and where did it snow on 1 January 2015?' 75 | 76 | snowEvents = [] 77 | 78 | for e in events: 79 | if 'Snow' in e.get('type'): 80 | snowEvents.append(e) 81 | 82 | for e in snowEvents: 83 | print 'Time: ' + str(e.when()) + ', Location: ' + e.get('latitude') +', ' + e.get('longitude') 84 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/fields/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Python field usage examples 2 | ================================================================== 3 | 4 | Abstract: This folder should contain usage examples of the python field implementation at a later point in time. 5 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/fields/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/CoreConceptsPy/GdalPy/examples/fields/__init__.py -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/fields/aspectCalc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Derive aspect values from a digital elevation model as an example of the focal function from the core concept 'field.' 6 | 7 | @OBSOLETE: THESE EXAMPLES ARE BASED ON ARCPY. 8 | """ 9 | 10 | __author__ = "Eric Ahlgren" 11 | __copyright__ = "Copyright 2015" 12 | __credits__ = ["Eric Ahlgren"] 13 | __license__ = "" 14 | __version__ = "0.1" 15 | __maintainer__ = "" 16 | __email__ = "" 17 | __date__ = "March 2015" 18 | __status__ = "Development" 19 | 20 | import sys 21 | 22 | sys.path = [ '.', '../..' ] + sys.path 23 | from utils import _init_log 24 | from fields import * 25 | 26 | log = _init_log("aspectCalc") 27 | 28 | # Import system modules 29 | import arcpy 30 | from arcpy import env 31 | from arcpy.sa import * 32 | import os 33 | 34 | # Set environment settings 35 | env.workspace = os.path.join("..","..","..","data","fields") 36 | 37 | # Set local variables 38 | inRaster = "CalPolyDEM.tif" 39 | outMeasurement = "DEGREE" 40 | 41 | # Check out the ArcGIS Spatial Analyst extension license 42 | arcpy.CheckOutExtension("Spatial") 43 | 44 | # Execute Aspect 45 | outAspect = Aspect(inRaster) 46 | 47 | # Save the output 48 | outAspect.save(os.path.join("..","..","..","data","fields","tmp","outAspect.tif")) -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/fields/slopeCalc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Derive slope values from a digital elevation model as an example of the focal function from the core concept 'field.' 6 | 7 | @OBSOLETE: THESE EXAMPLES ARE BASED ON ARCPY. 8 | """ 9 | 10 | __author__ = "Eric Ahlgren" 11 | __copyright__ = "Copyright 2015" 12 | __credits__ = ["Eric Ahlgren"] 13 | __license__ = "" 14 | __version__ = "0.1" 15 | __maintainer__ = "" 16 | __email__ = "" 17 | __date__ = "March 2015" 18 | __status__ = "Development" 19 | 20 | import sys 21 | 22 | sys.path = [ '.', '../..' ] + sys.path 23 | from utils import _init_log 24 | from fields import * 25 | 26 | log = _init_log("slopeCalc") 27 | 28 | # Import system modules 29 | import arcpy 30 | from arcpy import env 31 | from arcpy.sa import * 32 | import os 33 | 34 | # Set environment settings 35 | env.workspace = os.path.join("..","..","..","data","fields") 36 | 37 | # Set local variables 38 | inRaster = "CalPolyDEM.tif" 39 | outMeasurement = "DEGREE" 40 | 41 | # Check out the ArcGIS Spatial Analyst extension license 42 | arcpy.CheckOutExtension("Spatial") 43 | 44 | # Execute Slope 45 | outSlope = Slope(inRaster, outMeasurement) 46 | 47 | # Save the output 48 | outSlope.save(os.path.join("..","..","..","data","fields","tmp","outSlope.tif")) 49 | 50 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/fields/zonalArea.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Calculate area for 3 zones of study for a solar panel site-suitability analysis. Zone 1 is rooftops, zone 2 parking 6 | lots and zone 3 sloping grassland. This is an example of the zonal function from the core concept 'field.' 7 | 8 | @OBSOLETE: THESE EXAMPLES ARE BASED ON ARCPY. 9 | """ 10 | 11 | __author__ = "Eric Ahlgren" 12 | __copyright__ = "Copyright 2015" 13 | __credits__ = ["Eric Ahlgren"] 14 | __license__ = "" 15 | __version__ = "0.1" 16 | __maintainer__ = "" 17 | __email__ = "" 18 | __date__ = "March 2015" 19 | __status__ = "Development" 20 | 21 | import sys 22 | 23 | sys.path = [ '.', '../..' ] + sys.path 24 | from utils import _init_log 25 | from fields import * 26 | 27 | log = _init_log("slopeCalc") 28 | 29 | # Import system modules 30 | import arcpy 31 | from arcpy import env 32 | from arcpy.sa import * 33 | import os 34 | 35 | # Set environment settings 36 | env.workspace = os.path.join("..","..","..","data","fields") 37 | 38 | # Set local variables 39 | inZoneData = "zonalRast.tif" 40 | zoneField = "Value" 41 | cellSize = 1 42 | 43 | # Check out the ArcGIS Spatial Analyst extension license 44 | arcpy.CheckOutExtension("Spatial") 45 | 46 | # Execute ZonalStatistics 47 | outZonalGeometry = ZonalGeometry(inZoneData, zoneField, "AREA", cellSize) 48 | 49 | # Save the output 50 | outZonalGeometry.save(os.path.join("..","..","..","data","fields","tmp","zonalArea.tif")) -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/fields/zonalRadiation.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Calculate total incoming solar raditaion for 3 zones of study for a solar panel site-suitability analysis. 6 | Zone 1 is rooftops, zone 2 parking lots and zone 3 sloping grassland. Output is a table (.dbf) with the total 7 | insolation for each zone. This is an example of the zonal function from the core concept 'field.' 8 | 9 | @OBSOLETE: THESE EXAMPLES ARE BASED ON ARCPY. 10 | """ 11 | 12 | __author__ = "Eric Ahlgren" 13 | __copyright__ = "Copyright 2015" 14 | __credits__ = ["Eric Ahlgren"] 15 | __license__ = "" 16 | __version__ = "0.1" 17 | __maintainer__ = "" 18 | __email__ = "" 19 | __date__ = "March 2015" 20 | __status__ = "Development" 21 | 22 | import sys 23 | 24 | sys.path = [ '.', '../..' ] + sys.path 25 | from utils import _init_log 26 | from fields import * 27 | 28 | log = _init_log("slopeCalc") 29 | 30 | # Import system modules 31 | import arcpy 32 | from arcpy import env 33 | from arcpy.sa import * 34 | import os 35 | 36 | # Set environment settings 37 | env.workspace = os.path.join("..","..","..","data","fields") 38 | 39 | # Set local variables 40 | inZoneData = "zonalRast.tif" 41 | zoneField = "Value" 42 | inValueRaster = "insolation2014.tif" 43 | outTable = os.path.join("..","..","..","data","fields","tmp","zonalInsolation.dbf") 44 | 45 | 46 | # Check out the ArcGIS Spatial Analyst extension license 47 | arcpy.CheckOutExtension("Spatial") 48 | 49 | # Execute ZonalStatisticsAsTable 50 | outZSaT = ZonalStatisticsAsTable(inZoneData, zoneField, inValueRaster, 51 | outTable, "NODATA", "SUM") -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/locations/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Python location usage examples 2 | ===================================================================== 3 | 4 | Abstract: This folder should contain usage examples of the python location implementation at a later point in time. 5 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/locations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/CoreConceptsPy/GdalPy/examples/locations/__init__.py -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/networks/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Python network use cases 2 | =============================================================== 3 | 4 | Abstract: Python network use cases based on different network data. 5 | 6 | Contents 7 | ---------------------- 8 | 9 | * `synthetic_weighted_network.py`: Operations on a street network as examples for how to use the core concept 'network'. 10 | * `karate.py`: Operations on a social graph as examples for how to use the core concept 'network'. 11 | * `ucsb.py`: Operations on a street network as examples for how to use the core concept 'network'. 12 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/networks/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/CoreConceptsPy/GdalPy/examples/networks/__init__.py -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/networks/karate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Operations on a social graph as examples for how to use the core concept 'network' 6 | """ 7 | 8 | __author__ = "Michel Zimmer" 9 | __copyright__ = "Copyright 2014" 10 | __credits__ = ["Michel Zimmer"] 11 | __license__ = "" 12 | __version__ = "0.1" 13 | __maintainer__ = "" 14 | __email__ = "" 15 | __date__ = "December 2014" 16 | __status__ = "Development" 17 | 18 | import sys 19 | import itertools 20 | import networkx as nx 21 | 22 | sys.path = [ '.', '../..' ] + sys.path 23 | from utils import _init_log 24 | from networks import * 25 | 26 | log = _init_log("karate") 27 | 28 | 29 | print "Analysis of the network of friendships between the 34 members of a karate club at a US university, as described by Wayne Zachary in 1977." 30 | N = NetworkX() 31 | N._G = nx.read_gml('../data/networks/karate.gml') 32 | 33 | 34 | print "\nPeople who don't maintain a friendship inside the karate club:" 35 | a = [] 36 | for b in N.nodes(): 37 | if N.degree(b) == 0: 38 | a.append(b) 39 | assert len(a) == 0 40 | print " non" 41 | 42 | 43 | print "\nHow many friendships are there?\n %d" % len(N.edges()) 44 | 45 | 46 | print "\nAnd who maintains the highest number of friendships?" 47 | l = [] 48 | m = -1 49 | for n in iter(N.nodes()): 50 | o = len(N.breadthFirst(n, 1)) 51 | if o > m: 52 | l = [] 53 | m = o 54 | if o >= m: 55 | l.append(n) 56 | for p in l: 57 | q = N.breadthFirst(p, 1) 58 | q.remove(p) 59 | print " %d: %s" % (p, q) 60 | 61 | 62 | print "\nWe can look for a seperated group by checking if one member is connected to everybody else." 63 | c = N.nodes()[0] 64 | d = iter(N.nodes()) 65 | e = next(d) 66 | for f in d: 67 | assert N.connected(f, c) == True 68 | e = f 69 | print " All the members are connected." 70 | 71 | 72 | print "\nSo as a friend of a friend of a friend and so on everyone is connected to everybody else. But what's the highest number of people needed to create a connection between two members?" 73 | g = [] 74 | h = -1 75 | for i in itertools.combinations(N.nodes(), 2): 76 | j = N.distance(i[0], i[1]) 77 | if j > h: 78 | g = [] 79 | h = j 80 | if j >= h: 81 | g.append(i) 82 | assert h > -1 83 | print "It's %d and it's between these connections:" % (h-1) 84 | for k in g: 85 | print " %s" % N.shortestPath(k[0], k[1]) 86 | 87 | # QUICK DISPLAY 88 | # import matplotlib.pyplot as plt 89 | # pos=nx.spring_layout(N._G) 90 | # nx.draw_networkx_nodes(N._G,pos) 91 | # nx.draw_networkx_edges(N._G,pos) 92 | # nx.draw_networkx_labels(N._G,pos,dict(N._G.nodes()[i:i+2] for i in range(0, len(N._G.nodes()), 2))) 93 | # plt.axis('off') 94 | # plt.show() 95 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/networks/synthetic_weighted_network.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Operations on a street network as examples for how to use the core concept 'network' 6 | """ 7 | 8 | __author__ = "Michel Zimmer" 9 | __copyright__ = "Copyright 2014" 10 | __credits__ = ["Michel Zimmer"] 11 | __license__ = "" 12 | __version__ = "0.1" 13 | __maintainer__ = "" 14 | __email__ = "" 15 | __date__ = "December 2014" 16 | __status__ = "Development" 17 | 18 | import sys 19 | import networkx as nx 20 | import matplotlib.pyplot as plt 21 | 22 | sys.path = [ '.', '../..' ] + sys.path 23 | from utils import _init_log 24 | from networks import * 25 | 26 | log = _init_log("synthetic_weighted_network") 27 | 28 | print "\nShortest paths in the synthetic weighted network" 29 | N = NetworkX() 30 | 31 | # horizontal 32 | N.addEdge(1, 2, length = 5) 33 | N.addEdge(3, 4, length = 5) 34 | N.addEdge(4, 5, length = 4) 35 | N.addEdge(6, 7, length = 9) 36 | # vertical 37 | N.addEdge(1, 3, length = 1) 38 | N.addEdge(1, 4, length = 3) 39 | N.addEdge(2, 4, length = 5) 40 | N.addEdge(2, 5, length = 2) 41 | N.addEdge(6, 3, length = 8) 42 | N.addEdge(6, 4) 43 | N.addEdge(7, 4) 44 | N.addEdge(7, 5, length = 2) 45 | 46 | a = 3 47 | b = 5 48 | 49 | unweighted = N.shortestPath(a, b) 50 | weighted = N.shortestPath(a, b, weight = 'length') 51 | 52 | print 'Unweighted: %s' % (unweighted) 53 | print 'Weighted: %s' % (weighted) 54 | 55 | node_position = { 56 | 1: (2, 1), 57 | 2: (4, 1), 58 | 3: (1, 2), 59 | 4: (3, 2), 60 | 5: (5, 2), 61 | 6: (2, 3), 62 | 7: (4, 3) 63 | } 64 | 65 | node_labels = {} 66 | for i in N.nodes(): 67 | node_labels[i] = i 68 | 69 | edge_labels = {} 70 | for i in N.edges(True): 71 | x = i[2] 72 | if 'length' not in x: 73 | x['length'] = 1 74 | edge_labels[(i[0], i[1])] = x['length'] 75 | 76 | edge_color = ['black'] * len(N.edges()) 77 | for i in range(len(N.edges())): 78 | for j in range(len(unweighted)-1): 79 | if unweighted[j] == N.edges()[i][0] and unweighted[j+1] == N.edges()[i][1] or unweighted[j] == N.edges()[i][1] and unweighted[j+1] == N.edges()[i][0]: 80 | edge_color[i] = 'red' 81 | for j in range(len(weighted)-1): 82 | if weighted[j] == N.edges()[i][0] and weighted[j+1] == N.edges()[i][1] or weighted[j] == N.edges()[i][1] and weighted[j+1] == N.edges()[i][0]: 83 | edge_color[i] = 'blue' 84 | 85 | plt.figure().canvas.set_window_title('SYNTHETIC WEIGHTED NETWORK') 86 | nx.draw(N._G, node_position, edge_color=edge_color) 87 | nx.draw_networkx_labels(N._G, node_position, node_labels) 88 | nx.draw_networkx_edge_labels(N._G, node_position, edge_labels) 89 | plt.show() 90 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/networks/ucsb.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Operations on a street network as examples for how to use the core concept 'network' 6 | """ 7 | 8 | __author__ = "Michel Zimmer" 9 | __copyright__ = "Copyright 2014" 10 | __credits__ = ["Michel Zimmer"] 11 | __license__ = "" 12 | __version__ = "0.1" 13 | __maintainer__ = "" 14 | __email__ = "" 15 | __date__ = "December 2014" 16 | __status__ = "Development" 17 | 18 | import sys 19 | import itertools 20 | import networkx as nx 21 | import matplotlib.pyplot as plt 22 | 23 | sys.path = [ '.', '../..' ] + sys.path 24 | from utils import _init_log 25 | from networks import * 26 | 27 | log = _init_log("ucsb") 28 | 29 | print "\nShortest paths in the UCSB street network" 30 | N = NetworkX() 31 | 32 | node_ids = {} 33 | for edge in nx.read_shp('../data/networks/ucsb.shp').edges(data = True): 34 | sourceId = 0 35 | sourceCoordinates = edge[0] 36 | if sourceCoordinates in node_ids: 37 | sourceId = node_ids[sourceCoordinates] 38 | else: 39 | sourceId = len(N.nodes()) + 1 40 | N.addNode(sourceId, coordinates = sourceCoordinates) 41 | node_ids[sourceCoordinates] = sourceId 42 | targetId = 0 43 | targetCoordinates = edge[1] 44 | if targetCoordinates in node_ids: 45 | targetId = node_ids[targetCoordinates] 46 | else: 47 | targetId = len(N.nodes()) + 1 48 | N.addNode(targetId, coordinates = targetCoordinates) 49 | node_ids[targetCoordinates] = targetId 50 | N.addEdge(sourceId, targetId, length = edge[2]['length']) 51 | 52 | a = 22 53 | b = 86 54 | 55 | unweighted = N.shortestPath(a, b) 56 | weighted = N.shortestPath(a, b, weight = 'length') 57 | 58 | print 'Unweighted: %s' % (unweighted) 59 | print 'Weighted: %s' % (weighted) 60 | 61 | node_positions = {} 62 | for node in N.nodes(data = True): 63 | node_positions[node[0]] = node[1]['coordinates'] 64 | 65 | node_labels = {} 66 | for i in N.nodes(): 67 | if i in unweighted or i in weighted: 68 | node_labels[i] = i 69 | 70 | edge_color = ['black'] * len(N.edges()) 71 | for i in range(len(N.edges())): 72 | for j in range(len(unweighted)-1): 73 | if unweighted[j] == N.edges()[i][0] and unweighted[j+1] == N.edges()[i][1] or unweighted[j] == N.edges()[i][1] and unweighted[j+1] == N.edges()[i][0]: 74 | edge_color[i] = 'red' 75 | for j in range(len(weighted)-1): 76 | if weighted[j] == N.edges()[i][0] and weighted[j+1] == N.edges()[i][1] or weighted[j] == N.edges()[i][1] and weighted[j+1] == N.edges()[i][0]: 77 | edge_color[i] = 'blue' 78 | 79 | plt.figure().canvas.set_window_title('UCSB STREET NETWORK') 80 | nx.draw(N._G, node_positions, edge_color = edge_color, node_size = 10) 81 | nx.draw_networkx_labels(N._G, node_positions, node_labels) 82 | plt.show() 83 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/objects/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Python object usage examples 2 | =================================================================== 3 | 4 | Abstract: This folder should contain usage examples of the python object implementation at a later point in time. 5 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/objects/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/CoreConceptsPy/GdalPy/examples/objects/__init__.py -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/objects/roofsAboveMinInsolation.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Select all rooftops that recieve a minimum average of 3.5 kWh of insolation per day and create a new shapefile. This is an example of the property function 6 | from the core concept 'objects.' 7 | 8 | """ 9 | 10 | __author__ = "Eric Ahlgren" 11 | __copyright__ = "Copyright 2015" 12 | __credits__ = ["Eric Ahlgren"] 13 | __license__ = "" 14 | __version__ = "0.1" 15 | __maintainer__ = "" 16 | __email__ = "" 17 | __date__ = "March 2015" 18 | __status__ = "Development" 19 | 20 | import sys 21 | import os 22 | 23 | sys.path = [ '.', '../..' ] + sys.path 24 | from utils import _init_log 25 | 26 | # Import arcpy and set path to data 27 | import arcpy 28 | from arcpy import env 29 | 30 | env.workspace = os.path.join("..","..","..","data","objects") 31 | env.overwriteOutput = True 32 | 33 | 34 | # Set local variables 35 | in_features = "rooftops_pv.shp" 36 | out_feature_class = os.path.join("..","..","..","data","objects","tmp","roofs_aboveMinInsol.shp") 37 | where_clause = '"pvrooftop_solar2014.SUM" >= 1277500' 38 | 39 | # Execute Select 40 | arcpy.Select_analysis(in_features, out_feature_class, where_clause) -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/examples/objects/selectRooftopsNearRoads.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Abstract: Select all rooftops within 50 m of a road and create a new shapefile. This is an example of the relation function 6 | from the core concept 'objects.' 7 | 8 | """ 9 | 10 | __author__ = "Eric Ahlgren" 11 | __copyright__ = "Copyright 2015" 12 | __credits__ = ["Eric Ahlgren"] 13 | __license__ = "" 14 | __version__ = "0.1" 15 | __maintainer__ = "" 16 | __email__ = "" 17 | __date__ = "March 2015" 18 | __status__ = "Development" 19 | 20 | import sys 21 | import os 22 | 23 | sys.path = [ '.', '../..' ] + sys.path 24 | from utils import _init_log 25 | 26 | # Import arcpy and set path to data 27 | import arcpy 28 | from arcpy import env 29 | 30 | env.workspace = os.path.join("..","..","..","data","objects") 31 | env.overwriteOutput = True 32 | 33 | # Make a layer and select rooftops within 50 m of roads 34 | arcpy.MakeFeatureLayer_management('rooftops_pv.shp', 'rooftops_lyr') 35 | arcpy.SelectLayerByLocation_management('rooftops_lyr', 'WITHIN_A_DISTANCE', 'roads.shp',50) 36 | 37 | # If features matched criteria write them to a new feature class 38 | matchcount = int(arcpy.GetCount_management('rooftops_lyr').getOutput(0)) 39 | outfile = os.path.join("..","..","..","data","objects","tmp","roofs_within50mroads.shp") 40 | if matchcount == 0: 41 | print('no features matched spatial and attribute criteria') 42 | else: 43 | arcpy.CopyFeatures_management('rooftops_lyr',outfile ) 44 | print('{0} rooftops that matched criteria written to {1}'.format( 45 | matchcount, outfile)) -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/locations.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Module abstract goes here. 5 | """ 6 | 7 | __author__ = "Werner Kuhn and Andrea Ballatore" 8 | __copyright__ = "Copyright 2014" 9 | __credits__ = ["Werner Kuhn", "Andrea Ballatore"] 10 | __license__ = "" 11 | __version__ = "0.1" 12 | __maintainer__ = "" 13 | __email__ = "" 14 | __date__ = "August 2014" 15 | __status__ = "Development" 16 | 17 | from utils import _init_log 18 | from coreconcepts import CcLocation 19 | 20 | log = _init_log("location") 21 | 22 | class ExLoc(CcLocation): 23 | """ 24 | IGNORE THIS CLASS FOR THE MOMENT. 25 | A toy implementation of ALocate. 26 | """ 27 | 28 | def isAt( figure, ground ): 29 | # TODO: implementation with some geometric computation 30 | return True 31 | 32 | def isIn( figure, ground ): 33 | # TODO: implementation with some geometric computation 34 | return True 35 | 36 | def isPart( figure, ground ): 37 | # TODO: implementation with some geometric computation 38 | return False 39 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/makefile.py: -------------------------------------------------------------------------------- 1 | # This is a helper script to run the tests and examples where make does not work seamlessly *caugh* windows *caugh* ... 2 | 3 | import fnmatch 4 | import os 5 | import shutil 6 | import subprocess 7 | import sys 8 | import unittest 9 | 10 | examples = { 11 | 'events': [ 12 | 'example_1.py', 13 | 'example_2.py', 14 | 'example_3.py', 15 | 'earthquake/output_use_case.py', 16 | 'earthquake/input_use_case.py' 17 | ], 18 | 'fields': [], 19 | 'locations': [], 20 | 'networks': [ 21 | 'karate.py', 22 | 'synthetic_weighted_network.py', 23 | 'ucsb.py' 24 | ], 25 | 'objects': [] 26 | } 27 | 28 | def usage(): 29 | print 'Usage: python %s test-events|fields|locations|networks|objects|all' % (sys.argv[0]) 30 | print ' or: python %s example-events|fields|locations|networks|objects|all' % (sys.argv[0]) 31 | 32 | def clean(): 33 | shutil.rmtree('tmp') 34 | os.mkdir('tmp') 35 | for root, dirnames, filenames in os.walk('.'): 36 | for filename in fnmatch.filter(filenames, '*.pyc'): 37 | os.remove(os.path.join(root, filename)) 38 | 39 | def test(selector): 40 | suite = unittest.TestSuite() 41 | suite.addTest(unittest.defaultTestLoader.discover('test', selector, '..')) 42 | unittest.TextTestRunner().run(suite) 43 | 44 | def example(selector = None): 45 | for cc in examples: 46 | if selector == None or cc == selector: 47 | for f in examples[cc]: 48 | subprocess.call('python examples/' + cc + '/' + f, shell = True) 49 | 50 | if __name__ == '__main__': 51 | if os.path.dirname(os.path.abspath(__file__)) != os.getcwd(): 52 | print 'This script should be run from inside of ' + os.path.dirname(os.path.abspath(__file__)) 53 | elif len(sys.argv) >= 2: 54 | clean() 55 | if sys.argv[1] == 'clean': 56 | pass 57 | elif sys.argv[1] == 'test-events': 58 | test('events') 59 | elif sys.argv[1] == 'test-fields': 60 | test('fields') 61 | elif sys.argv[1] == 'test-locations': 62 | print "No examples and no tests for locations yet." 63 | elif sys.argv[1] == 'test-networks': 64 | test('networks') 65 | elif sys.argv[1] == 'test-objects': 66 | test('objects') 67 | elif sys.argv[1] == 'test-all': 68 | test('*') 69 | elif sys.argv[1] == 'example-events': 70 | example('events') 71 | elif sys.argv[1] == 'example-fields': 72 | print "No examples for fields yet. Have a look at the tests." 73 | elif sys.argv[1] == 'example-locations': 74 | print "No examples and no tests for locations yet." 75 | elif sys.argv[1] == 'example-networks': 76 | example('networks') 77 | elif sys.argv[1] == 'example-objects': 78 | print "No examples for objects yet. Have a look at the tests." 79 | elif sys.argv[1] == 'example-all': 80 | example() 81 | else: 82 | usage() 83 | else: 84 | usage() 85 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/networks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Abstract: These classes are implementations of the core concept 'network', as defined in coreconcepts.py 5 | The class is written in an object-oriented style. 6 | """ 7 | 8 | __author__ = "Michel Zimmer" 9 | __copyright__ = "Copyright 2014" 10 | __credits__ = ["Michel Zimmer", "Andrea Ballatore"] 11 | __license__ = "" 12 | __version__ = "0.1" 13 | __maintainer__ = "" 14 | __email__ = "" 15 | __date__ = "December 2014" 16 | __status__ = "Development" 17 | 18 | import networkx as nx 19 | 20 | from utils import _init_log 21 | from coreconcepts import CcNetwork 22 | 23 | log = _init_log("networks") 24 | 25 | class NetworkX(CcNetwork): 26 | """ 27 | NetworkX wrapper implementation for core concept 'network' 28 | """ 29 | 30 | def __init__( self ): 31 | self._G = nx.Graph() 32 | 33 | def nodes( self, data = False ): 34 | """ @return a copy of the graph nodes in a list """ 35 | return self._G.nodes(data = data) 36 | 37 | def edges( self, data = False ): 38 | """ @return list of edges """ 39 | return self._G.edges(data = data) 40 | 41 | def addNode( self, n, **attr ): 42 | """ Add node n with the attributes attr """ 43 | self._G.add_node(n, attr) 44 | 45 | def addEdge( self, u, v, **attr ): 46 | """ Add an edge with the attributes attr between u and v """ 47 | self._G.add_edge(u, v, attr) 48 | 49 | def connected( self, u, v ): 50 | """ @return whether node v can be reached from node u """ 51 | try: 52 | self.shortestPath(u, v) 53 | return True 54 | except nx.NetworkXNoPath: 55 | return False 56 | 57 | def shortestPath( self, source, target, weight = None ): 58 | """ @return shortest path in the graph """ 59 | if weight == None: 60 | return nx.shortest_path(self._G, source, target) 61 | else: 62 | return nx.shortest_path(self._G, source, target, weight = weight) 63 | 64 | def degree( self, n ): 65 | """ @return number of the nodes connected to the node n """ 66 | return len(self._G.neighbors(n)) 67 | 68 | def distance( self, source, target ): 69 | """ @return the length of the shortest path from the source to the target """ 70 | return nx.shortest_path_length(self._G, source, target) 71 | 72 | def breadthFirst( self, node, cutoff ): 73 | """ @return all nodes within the distance cutoff from node in this network """ 74 | return nx.single_source_shortest_path(self._G, node, cutoff).keys() 75 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/test/README.md: -------------------------------------------------------------------------------- 1 | Unit tests for the coreconcept implementation in Python 2 | 3 | General docs for UNIT TESTS: 4 | https://docs.python.org/2/library/unittest.html 5 | -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/CoreConceptsPy/GdalPy/test/__init__.py -------------------------------------------------------------------------------- /CoreConceptsPy/GdalPy/test/objects_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # TODO: don't use print (use log instead) 5 | 6 | """ 7 | Abstract: Unit tests for the implementations of the core concept 'object' 8 | """ 9 | 10 | __author__ = "Eric Ahlgren" 11 | __copyright__ = "Copyright 2014" 12 | __credits__ = ["Eric Ahlgren", "Andrea Ballatore"] 13 | __license__ = "" 14 | __version__ = "0.1" 15 | __maintainer__ = "" 16 | __email__ = "" 17 | __date__ = "December 2014" 18 | __status__ = "Development" 19 | 20 | import sys 21 | import os 22 | import unittest 23 | 24 | sys.path = [ '.', '..' ] + sys.path 25 | from utils import _init_log 26 | from objects import * 27 | 28 | log = _init_log("objects_test") 29 | 30 | class TestArcShpObject(unittest.TestCase): 31 | 32 | def test_bounds( self ): 33 | #Get objects from shapefiles 34 | shapefile1 = os.path.join("..","..","data","objects","Rooftops.shp") 35 | shapefile2 = os.path.join("..","..","data","objects","ViablePVArea.shp") 36 | roofObj = ArcShpObject( shapefile1, 0 ) 37 | pvObj = ArcShpObject( shapefile2, 236 ) 38 | #test getBounds on roof object - Poultry Science building 39 | print "\nTest shapefile objects - getBounds for CalPoly roof" 40 | roofObj = ArcShpObject ( shapefile1, 0 ) 41 | roofBounds = roofObj.bounds() 42 | roofBounds = ( round( roofBounds[0],2 ),round( roofBounds[1],2 ),round( roofBounds[2],2 ),round( roofBounds[3],2 ) ) 43 | print "\nBounding box coordinates, UTM Zone 10N, in form (MinX, MaxX, MinY, MaxY):\n",roofBounds,"\n" 44 | self.assertTupleEqual( roofBounds, ( 710915.55, 710983.25, 3910040.96, 3910095.28 ) ) 45 | 46 | def test_relation( self ): 47 | #Get objects from shapefiles 48 | shapefile1 = os.path.join("..","..","data","objects","Rooftops.shp") 49 | shapefile2 = os.path.join("..","..","data","objects","ViablePVArea.shp") 50 | roofObj = ArcShpObject( shapefile1, 0 ) 51 | pvObj = ArcShpObject( shapefile2, 236 ) 52 | #test hasRelation for PV object within roof object 53 | rel = pvObj.relation( roofObj,'Within' ) 54 | self.assertEqual( rel, True ) 55 | 56 | def test_property( self ): 57 | #Get objects from shapefiles 58 | shapefile1 = os.path.join("..","..","data","objects","Rooftops.shp") 59 | roofObj = ArcShpObject( shapefile1, 0 ) 60 | #test getProprty for Poultry Science building name 61 | roofName = roofObj.property( 'name' ) 62 | self.assertEqual( roofName, "Poultry Science" ) 63 | 64 | def test_identity( self ): 65 | shapefile1 = os.path.join("..","..","data","objects","Rooftops.shp") 66 | roofObj = ArcShpObject( shapefile1, 0 ) 67 | self.assertTrue( roofObj.identity( roofObj ) ) 68 | 69 | -------------------------------------------------------------------------------- /CoreConceptsPy/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Python 2 | ============================================== 3 | 4 | Abstract: Specifications and implementation of the core concepts in Python. 5 | 6 | See the [Readme](../README.md) in the parent directory for general information about the Core Concepts. 7 | 8 | Currently, each implementation is in a proof of concept state and should not be considered stable for a production environment. 9 | 10 | Contents 11 | ---------------------- 12 | 13 | - `/ArcPy`: Implementation leveraging ArcGIS processing 14 | - `/GdalPy`: Implementation leveraging GDAL processing 15 | -------------------------------------------------------------------------------- /CoreConceptsRdf/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - RDF 2 | ============================================= 3 | 4 | Abstract: RDF files and ontologies 5 | 6 | Contents 7 | ---------------------- 8 | 9 | * `event/`: RDF event ontologies and examples. 10 | * `coreconcepts_rdfs.rdf`: Preliminary RDF schema of the core concepts 11 | 12 | 13 | RDFS vs. OWL 14 | ---------------------- 15 | OWL offers extended functionality on top of RDFS. OWL ontologies still need to use RDFS terms such as `rdfs:range`, `rdfs:domain`, `rdfs:subClassOf`, `rdfs:subPropertyOf`, `rdfs:label`, `rdfs:comment` because OWL does not offer this functionality. 16 | 17 | Additional functionalities of OWL are: 18 | 19 | ####Property Restrictions 20 | 21 | - **value constraints** 22 | 23 | You can define that all values or some values need to come from another class or that a property has a specifc value. 24 | 25 | - **cardinality constraints** 26 | 27 | You can define the minimum cardinality, maximum cardinality or the cardinality of a property. 28 | 29 | - **FunctionalProperty** 30 | 31 | Assigns a maximum cardinality of 1 to a property. 32 | 33 | - **InverseFunctionalProperty** 34 | 35 | Assigns a maximum cardinality of 1 to the inverse property. 36 | 37 | ####Inference with additional properties 38 | 39 | Additional properties make inference possible. You can define the inverse property of a property, the equivalent property of a property and you can make a property transitive or symmetric. 40 | 41 | ####Versatile class descriptions 42 | 43 | You can describe a class as an enumeration, intersection, union and/or complement of other classes. Additionally, you can describe classes with property restrictions. 44 | 45 | ####Individuals 46 | 47 | You can say that an individual is the same as another individual or different from another individual. 48 | 49 | ####Annotations and Header 50 | 51 | You can define a header that contains information about the ontology including version, title, imports of other ontologies, a prior ontology version, the compatibility with that prior version and deprecated classes and properties. 52 | -------------------------------------------------------------------------------- /CoreConceptsRdf/event/event_rdfs.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 11 | 12 | 13 | ]> 14 | 15 | 16 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /CoreConceptsRdf/event/event_ttl.owl: -------------------------------------------------------------------------------- 1 | #Abstract: OWl ontology for the core concept event written in Turtle 2 | #Author: Marc Tim Thiemann 3 | 4 | @base . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix xsd: . 8 | @prefix owl: . 9 | @prefix owl2: . 10 | @prefix dc: . 11 | 12 | a owl:Ontology ; 13 | owl:versionInfo "v 1 2015/03/03" ; 14 | dc:title "Core Concepts - Event Ontology" ; 15 | dc:description "An ontology written for the event core concept in Turtle Syntax" . 16 | 17 | :Event a owl:Class . 18 | :RepetitiveEvent a owl:Class . 19 | :Attribute a owl:Class ; 20 | rdfs:subClassOf 21 | [a owl:Restriction ; 22 | owl:onProperty :key ; 23 | owl:cardinality 1], 24 | [a owl:Restriction ; 25 | owl:onProperty :value ; 26 | owl:cardinality 1] . 27 | 28 | :hasAttribute a owl:ObjectProperty ; 29 | rdfs:domain :Event ; 30 | rdfs:range :Attribute . 31 | 32 | :key a owl:DatatypeProperty ; 33 | rdfs:domain :Attribute ; 34 | rdfs:range xsd:Literal . 35 | 36 | :value a owl:DatatypeProperty ; 37 | rdfs:domain :Attribute ; 38 | rdfs:range xsd:Literal . 39 | 40 | :startTime a owl:DatatypeProperty , 41 | owl:FunctionalProperty ; 42 | rdfs:domain :Event ; 43 | rdfs:range xsd:dateTime . 44 | 45 | :endTime a owl:DatatypeProperty , 46 | owl:FunctionalProperty ; 47 | rdfs:domain :Event ; 48 | rdfs:range [ 49 | a rdfs:Datatype ; 50 | owl:onDatatype xsd:dateTime ; 51 | owl:withRestrictions ( [xsd:minInclusive :startTime] ) 52 | ] . 53 | 54 | :before a owl:ObjectProperty , 55 | owl:TransitiveProperty , 56 | owl2:AsymmetricProperty , 57 | owl2:IrreflexiveProperty ; 58 | owl:inverseOf :after ; 59 | rdfs:domain :Event ; 60 | rdfs:range :Event . 61 | 62 | :after a owl:ObjectProperty , 63 | owl:TransitiveProperty , 64 | owl2:AsymmetricProperty , 65 | owl2:IrreflexiveProperty ; 66 | rdfs:domain :Event ; 67 | rdfs:range :Event . 68 | 69 | :during a owl:ObjectProperty , 70 | owl:TransitiveProperty , 71 | owl2:ReflexiveProperty ; 72 | rdfs:domain :Event ; 73 | rdfs:range :Event . 74 | 75 | :temporalOverlap a owl:ObjectProperty , 76 | owl:SymmetricProperty , 77 | owl2:IrreflexiveProperty ; 78 | rdfs:domain :Event ; 79 | rdfs:range :Event . 80 | 81 | :temporalIntersection a owl:ObjectProperty , 82 | owl:SymmetricProperty , 83 | owl2:IrreflexiveProperty ; 84 | rdfs:domain :Event ; 85 | rdfs:range :Event . 86 | -------------------------------------------------------------------------------- /CoreConceptsRdf/event/event_xml_2.owl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | ]> 17 | 18 | 19 | 28 | 29 | 30 | 31 | v 1 2015/03/03 32 | Core Concepts - Event Ontology 33 | An ontology written for the event core concept in RDF Syntax 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 1 44 | 45 | 46 | 47 | 48 | 49 | 1 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /CoreConceptsRdf/event/examples/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - RDF event examples 2 | ========================================================= 3 | 4 | Abstract: RDF event data examples and Sparql queries 5 | 6 | Contents 7 | ---------------------- 8 | 9 | * `earthquake/`: RDF files and SPARQL queries of the earthquake example. 10 | * `ontology/`: Use cases and SPARQL queries based on the owl ontologies in the folder (`CoreConceptsRdf/events/`). 11 | -------------------------------------------------------------------------------- /CoreConceptsRdf/event/examples/earthquake/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - RDF earthquake example 2 | ========================================================== 3 | 4 | Abstract: RDF files and SPARQL queries of the earthquake example. 5 | 6 | Contents 7 | ---------------------- 8 | 9 | * `earthquake.rdf`: RDF schema defining an earthquake class. 10 | * `sparql_queries.md`: Example Sparql queries for the RDF output in the file (`test.rdf`). 11 | * `test.rdf`: RDF output generated by the EarthquakeRdfWriter. The RDF output is also used as RDF input by the EarthquakeRdfReader. 12 | -------------------------------------------------------------------------------- /CoreConceptsRdf/event/examples/earthquake/earthquake.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 11 | 12 | 13 | ]> 14 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CoreConceptsRdf/event/examples/earthquake/sparql_queries.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | SPARQL Queries 7 | ============================================= 8 | 9 | This file contains example SPARQL queries for the earthquake class RDF output located in the file `test.rdf`. 10 | The RDF file was loaded in a graph on a local Virtuoso server and the following SPARQL queries were run against the RDF graph. 11 | 12 | Get all earthquakes with a magnitude of 2.5 or higher: 13 | 14 | ``` 15 | PREFIX eq: 16 | PREFIX lode: 17 | 18 | SELECT ?latitude ?longitude ?place ?time ?magnitude WHERE { 19 | ?s rdf:type eq:Earthquake; 20 | dbpprop:magnitude ?magnitude; 21 | geo:lat ?latitude; 22 | geo:long ?longitude; 23 | lode:atTime ?time; 24 | lode:atPlace ?place 25 | FILTER(?magnitude > 2.5) 26 | } 27 | ORDER BY ?magnitude 28 | ``` 29 | 30 | 31 | Get all earthquakes of the first 7 days of December 2014: 32 | 33 | ``` 34 | PREFIX eq: 35 | PREFIX lode: 36 | 37 | SELECT ?latitude ?longitude ?place ?time ?magnitude WHERE { 38 | ?s rdf:type eq:Earthquake; 39 | dbpprop:magnitude ?magnitude; 40 | geo:lat ?latitude; 41 | geo:long ?longitude; 42 | lode:atTime ?time; 43 | lode:atPlace ?place 44 | FILTER (?time < "2014-12-06T23:59:59-08:00"^^xsd:dateTime) 45 | } 46 | ORDER BY ?time 47 | ``` 48 | 49 | 50 | Get all earthquakes in the Northern hemisphere: 51 | 52 | ``` 53 | PREFIX eq: 54 | PREFIX lode: 55 | 56 | SELECT ?latitude ?longitude ?place ?time ?magnitude WHERE { 57 | ?s rdf:type eq:Earthquake; 58 | dbpprop:magnitude ?magnitude; 59 | geo:lat ?latitude; 60 | geo:long ?longitude; 61 | lode:atTime ?time; 62 | lode:atPlace ?place 63 | FILTER (?latitude >= 0) 64 | } 65 | ORDER BY ?latitude 66 | ``` 67 | 68 | 69 | Get all earthquakes in the Western Hemisphere: 70 | 71 | ``` 72 | PREFIX eq: 73 | PREFIX lode: 74 | 75 | SELECT ?latitude ?longitude ?place ?time ?magnitude WHERE { 76 | ?s rdf:type eq:Earthquake; 77 | dbpprop:magnitude ?magnitude; 78 | geo:lat ?latitude; 79 | geo:long ?longitude; 80 | lode:atTime ?time; 81 | lode:atPlace ?place 82 | FILTER(?longitude < 0) 83 | } 84 | ORDER BY DESC(?longitude) 85 | ``` 86 | 87 | 88 | Get all earthquakes near California: 89 | 90 | ``` 91 | PREFIX eq: 92 | PREFIX lode: 93 | 94 | SELECT ?latitude ?longitude ?place ?time ?magnitude WHERE { 95 | ?s rdf:type eq:Earthquake; 96 | dbpprop:magnitude ?magnitude; 97 | geo:lat ?latitude; 98 | geo:long ?longitude; 99 | lode:atTime ?time; 100 | lode:atPlace ?place 101 | FILTER regex(?place, "California", "i") 102 | } 103 | ORDER BY ?magnitude 104 | ``` 105 | -------------------------------------------------------------------------------- /CoreConceptsRdf/event/examples/ontology/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Ontology use cases 2 | ========================================================== 3 | 4 | Abstract: Use cases and SPARQL queries for the RDF schema and owl ontologies located in the CoreConceptsRdf/events folder. 5 | 6 | The RDF file (`owl_ontology.rdf`) contains use cases for the ontologies (`event_ttl.owl`) and (`event_xml.owl`) located in the folder (`CoreConceptsRdf/event`). 7 | The RDF file (`owl_ontology_2.rdf`) contains use cases for the ontology (`event_xml_2.owl`) located in the folder (`CoreConceptsRdf/event`). 8 | The RDF file (`owl_ontology_3.rdf`) contains use cases with real event data for the ontology (`event_xml.owl`) located in the folder (`CoreConceptsRdf/event`). 9 | The RDF file (`rdfs_ontology.rdf) contains use cases for the RDF schema (`event_rdfs.rdf`) located in the folder (`CoreConceptsRdf/event`). 10 | 11 | Contents 12 | ---------------------- 13 | 14 | * `owl_ontology.rdf`: RDF data using the owl ontologies (`event_ttl.owl`) and (`event_xml.owl`) located in the folder (`CoreConceptsRdf/event`). 15 | * `owl_ontology_2.rdf`: RDF data using the owl ontology (`event_xml_2.owl`) located in the folder (`CoreConceptsRdf/event`). 16 | * `owl_ontology_3.rdf`: RDF data with real event data using the owl ontology (`event_xml.owl`) located in the folder (`CoreConceptsRdf/event`). 17 | * `rdfs_ontology.rdf`: RDF data using the RDF schema (`event_rdfs.rdf`) located in the folder (`CoreConceptsRdf/event`). 18 | * `sparql_queries.md`: This file contains SPARQL queries to test the event owl ontology (`event_xml.owl`) with RDF data from (`owl_ontology.rdf`). 19 | * `sparql_queries_2.md`: This file contains SPARQL queries to test the event owl ontology (`event_xml_2.owl`) with RDF data from (`owl_ontology_2.rdf`). 20 | * `sparql_queries_3.md`: This file contains SPARQL queries to test the event owl ontology (`event_xml.owl`) with real RDF event data from (`owl_ontology_3.rdf`). 21 | -------------------------------------------------------------------------------- /CoreConceptsRdf/event/examples/ontology/rdfs_ontology.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | ]> 15 | 16 | 17 | 22 | 23 | 24 | 25 | Afternoon 26 | The time between noon and evening. 27 | 2015-02-09T12:00:00 28 | 2015-02-09T17:59:59 29 | 30 | 31 | 32 | 33 | 34 | Evening 35 | The time between afternoon and night. 36 | 2015-02-09T18:00:00 37 | 2015-02-09T23:59:59 38 | 39 | 40 | 41 | 42 | 43 | 44 | Night 45 | The time between evening and morning. 46 | 2015-02-10T00:00:00 47 | 2015-02-10T05:59:59 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /data/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Data 2 | ============================================ 3 | 4 | Abstract: Contains example data for the following core concepts: event, fields, network and object. 5 | 6 | Contents 7 | ---------------------- 8 | 9 | * `objects/`: Object example data. 10 | * `fields/`: Field example data. 11 | * `networks/`: Network example data. 12 | * `events/`: Event example data. 13 | 14 | Granularity and accuracy data will be added with examples. 15 | -------------------------------------------------------------------------------- /data/events/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Events Data 2 | ---------------------- 3 | 4 | Abstract: Event data that is used in the Python Event examples. 5 | 6 | Contents 7 | ---------------------- 8 | 9 | * `course_data.csv`: A CSV file that contains course data of the UCSB Winter Quarter 2014. The fields for each course are: 10 | Term,Session,Acad Group,Class Nbr,Subject,Catalog Nbr,Section,Course Title,Component,Codes,M,T,W,TH,F,S,SU,Start Date,End Date,Time,Location,Instructor,Units. 11 | * `earthquake_data.csv`: A CSV file that contains global earthquake events of December 2014. The fields for each earthquake are: 12 | time,latitude,longitude,depth,mag,magType,nst,gap,dmin,rms,net,id,updated,place,type 13 | * `weather_data.txt`: A text file that contains US weather data from 1 January 2015. Each row includes: datetime, latitude, longitude, weather type 14 | -------------------------------------------------------------------------------- /data/fields/CalPolyDEM.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/fields/CalPolyDEM.tif -------------------------------------------------------------------------------- /data/fields/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Fields Data 2 | ---------------------- 3 | testField.tif - a 50x50 pixel subset of the CalPolyDEM.tif GeoTiff described below 4 | zone.tif - a binary zone raster with the same extent as testField. A value of 1 represents elevation greater than or equal to 118 m. 5 | CalPolyDEM.tif - a Digital Elevation Model of the CalPoly campus (see details below). 6 | 7 | GeoTiff used for PV site-suitability analysis for the CalPoly San Luis Obispo campus. Acquired from OpenTopography, January 2014. 8 | 9 | The file included here is first-return LiDAR data ("highest hit"). 10 | 11 | Original metadata included below. 12 | ---------------------- 13 | 14 | Dataset Information: 15 | 16 | Dataset Name: PG&E Diablo Canyon Power Plant (DCPP): San Simeon, CA Central Coast(CA13_SAN_SIM) 17 | 18 | Dataset Acknowledgement: 19 | Pacific Gas and Electric Company (PG&E) shall not be held liable for improper or incorrect use of these data. Data and related graphics (e.g., GIF or JPG format files) are not legal documents and are not intended to be used as such. The information contained in the data is dynamic and may change over time. The data are not better than the original sources from which they were derived. It is the responsibility of the data user to use the data appropriately and consistently within the limitations of geospatial data in general and these data in particular. The related graphics are intended to aid the data user in acquiring relevant data; it is not appropriate to use the related graphics as data. PG&E gives no warranty, expressed or implied, as to the accuracy, reliability, or completeness of these data. It is strongly recommended that these data are directly acquired from PG&E and not indirectly through other sources which may have changed the data in some way. Although these data have been processed successfully on computer systems by PG&E and its authorized representatives, no warranty expressed or implied is made regarding the utility of the data on other systems for general or scientific purposes, nor shall the act of distribution constitute any such warranty. This disclaimer applies both to individual use of the data and aggregate use with other data. 20 | 21 | Full Dataset Metadata: http://opentopo.sdsc.edu/gridsphere/gridsphere?cid=geonlidarframeportlet&gs_action=datasetMetadata&otCollectionID=OT.032013.26910.2 22 | 23 | Horizontal Coordinates: UTM Z10N NAD83 (2011) METERS 24 | Vertical Coordinates: NAVD88 GEOID12A 25 | 26 | Data Access Acknowledgement: This material is based on [data, processing] services provided by the OpenTopography Facility with support from the National Science Foundation under NSF Award Numbers 0930731 & 0930643 27 | 28 | Job Description: 29 | User:ecahlgren@umail.ucsb.edu 30 | Job ID: raster13907763994522006199522 31 | Title: CalPoly PV Analysis 32 | Description: 33 | 34 | Job Processing Result: 35 | Submission Time: 2014-01-26 14:46:40 36 | Completion Time: 2014-01-26 14:48:29 37 | Duration: 109 seconds 38 | Status: Done 39 | 40 | Data Selection Coordinates: 41 | Xmin: 711744.138 42 | Xmax: 713589.914 43 | Ymin: 3908256.445 44 | Ymax: 3910109.528 45 | 46 | Input & Output Options: 47 | Data Type: SDEM 48 | Output Format: GeoTiff 49 | Layer Type: Bare Earth, Highest Hit, Orthophotograph 50 | Include SRTM Data: No -------------------------------------------------------------------------------- /data/fields/insolation2014.tfw: -------------------------------------------------------------------------------- 1 | 1.0000000000 2 | 0.0000000000 3 | 0.0000000000 4 | -1.0000000000 5 | 710864.0000000000 6 | 3910169.0000000000 7 | -------------------------------------------------------------------------------- /data/fields/insolation2014.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/fields/insolation2014.tif -------------------------------------------------------------------------------- /data/fields/insolation2014.tif.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NEAREST 5 | 6 | 7 | 8 | 9 | 108.8656387329102 10 | 2605180.25 11 | 256 12 | 1 13 | 0 14 | 4038|3169|3369|3378|3559|3732|3863|3868|3936|3826|3874|3872|4002|4138|4257|4331|4764|4700|4921|4885|5068|5247|5263|5033|5101|5245|5276|5483|5469|5678|5697|6014|5892|5999|6003|5982|6164|5979|6029|6063|6159|6202|6215|6334|6210|6472|6393|6458|6754|6735|6789|6894|6896|7006|7085|7474|7158|7485|7399|7552|7719|7497|7634|7832|7845|7858|7840|7981|7935|8086|8297|8172|8514|8553|8498|8730|8826|9029|8863|9044|9155|9328|9364|9351|9486|9624|9600|9747|9748|9816|9813|9936|10132|9978|10185|10456|10368|10584|10720|10614|10704|10921|10933|11237|11362|11396|11523|11860|11846|11646|11991|12078|12215|12280|12423|12366|12595|12684|12796|13056|12998|13103|13469|13369|13633|13710|13834|13897|14103|14437|14453|14545|14893|15292|15256|15307|15639|15832|16092|16234|16238|16688|16666|17076|17250|17275|17518|17841|18081|17951|18476|18204|18928|18993|19133|19318|19768|19685|20013|20193|20403|20878|20967|21567|21800|21814|22361|22559|23168|22708|23245|23688|24041|23921|24621|24605|25023|25110|25273|25679|25977|25812|26255|26684|27196|27571|27846|28028|28048|28449|29258|29550|29989|30292|30854|31960|32655|32817|33767|34417|35183|36154|36934|38106|39110|40306|41354|42796|44302|46193|47781|50479|53019|56957|60767|65646|71695|79689|90778|101602|109794|111361|105560|96058|81218|70782|63278|56227|50280|45390|41950|38478|35544|33184|31317|29560|28412|27523|26026|24760|23294|21457|19811|19258|18146|16909|15792|14305|12754|11467|9884|5977|2175|162|6|1 15 | 16 | 17 | 18 | 108.86563873291 19 | 2605180.25 20 | 1787854.929499 21 | 601496.55124522 22 | 1 23 | 1 24 | 25 | 361798101159.893 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /data/fields/insolation2014.tif.ovr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/fields/insolation2014.tif.ovr -------------------------------------------------------------------------------- /data/fields/log: -------------------------------------------------------------------------------- 1 | 201503251242 0 2 0Eric C:\Users\Eric\Documents\Aptana Studio 3 Workspace\ConceptsOfSpatialInformation\data\fields\Slope_CalPol1 = SLOPE(C:\Users\Eric\Documents\Aptana Studio 3 Workspace\ConceptsOfSpatialInformation\data\fields\CalPolyDEM.tif, 1.0, DEGREE) 2 | 201503251245 0 3 0Eric C:\Users\Eric\Documents\Aptana Studio 3 Workspace\ConceptsOfSpatialInformation\data\fields\Aspect_CalPo1 = ASPECT(C:\Users\Eric\Documents\Aptana Studio 3 Workspace\ConceptsOfSpatialInformation\data\fields\CalPolyDEM.tif) 3 | 201503251356 0 1 0Eric C:\Users\Eric\Documents\Aptana Studio 3 Workspace\ConceptsOfSpatialInformation\data\fields\Slope_CalPol1 = SLOPE(C:\Users\Eric\Documents\Aptana Studio 3 Workspace\ConceptsOfSpatialInformation\data\fields\CalPolyDEM.tif, 1.0, DEGREE) 4 | 201503251429 0 0 0Eric C:\Users\Eric\Documents\Aptana Studio 3 Workspace\ConceptsOfSpatialInformation\data\fields\ZonalGe_zona1 = ZONALArea(C:\Users\Er 5 | 201503251432 0 0 0Eric C:\Users\Eric\Documents\Aptana Studio 3 Workspace\ConceptsOfSpatialInformation\data\fields\ZonalGe_zona1 = ZONALArea(C:\Users\Er 6 | 201503251436 0 2 0Eric C:\Users\Eric\Documents\Aptana Studio 3 Workspace\ConceptsOfSpatialInformation\data\fields\Aspect_CalPo1 = ASPECT(C:\Users\Eric\Documents\Aptana Studio 3 Workspace\ConceptsOfSpatialInformation\data\fields\CalPolyDEM.tif) 7 | -------------------------------------------------------------------------------- /data/fields/testField.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/fields/testField.tif -------------------------------------------------------------------------------- /data/fields/tmp/outAspect.tfw: -------------------------------------------------------------------------------- 1 | 1.0000000000 2 | 0.0000000000 3 | 0.0000000000 4 | -1.0000000000 5 | 711744.0000000000 6 | 3910110.0000000000 7 | -------------------------------------------------------------------------------- /data/fields/tmp/outAspect.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/fields/tmp/outAspect.tif -------------------------------------------------------------------------------- /data/fields/tmp/outAspect.tif.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Generic 4 | 5 | 6 | 7 | -1 8 | 360 9 | 195.93993282667 10 | 90.092450495175 11 | 1 12 | 1 13 | 14 | 8116.64963622555 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /data/fields/tmp/outSlope.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | PROJCS["NAD_1983_2011_UTM_Zone_10N",GEOGCS["GCS_NAD_1983_2011",DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],VERTCS["NAVD_1988",VDATUM["North_American_Vertical_Datum_1988"],PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]]] 3 | 4 | Generic 5 | 6 | 7 | -3.40282346638529E+038 8 | 9 | 10 | -------------------------------------------------------------------------------- /data/fields/tmp/outSlope.tfw: -------------------------------------------------------------------------------- 1 | 1.0000000000 2 | 0.0000000000 3 | 0.0000000000 4 | -1.0000000000 5 | 711744.0000000000 6 | 3910110.0000000000 7 | -------------------------------------------------------------------------------- /data/fields/tmp/outSlope.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/fields/tmp/outSlope.tif -------------------------------------------------------------------------------- /data/fields/tmp/outSlope.tif.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Generic 4 | 5 | 6 | 7 | 0 8 | 87.499786376953 9 | 25.27282867793 10 | 23.551886886213 11 | 1 12 | 1 13 | 14 | 554.691375900976 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /data/fields/tmp/zonalArea.tfw: -------------------------------------------------------------------------------- 1 | 1.0000000000 2 | 0.0000000000 3 | 0.0000000000 4 | -1.0000000000 5 | 711744.0000000000 6 | 3910107.0945999995 7 | -------------------------------------------------------------------------------- /data/fields/tmp/zonalArea.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/fields/tmp/zonalArea.tif -------------------------------------------------------------------------------- /data/fields/tmp/zonalArea.tif.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Generic 4 | 5 | 6 | 7 | 13074 8 | 63832 9 | 49679.794526472 10 | 17390.881451661 11 | 1 12 | 1 13 | 14 | 302442757.665738 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /data/fields/tmp/zonalInsolation.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/fields/tmp/zonalInsolation.dbf -------------------------------------------------------------------------------- /data/fields/tmp/zonalInsolation.dbf.xml: -------------------------------------------------------------------------------- 1 | 2 | 20150325150528001.0North American Profile of ISO19115 2003TRUEZonalStatisticsAsTable ..\..\..\data\fields\zonalRast.tif Value ..\..\..\data\fields\insolation2014.tif ..\..\..\data\fields\tmp\zonalInsolation.dbf NODATA SUM 3 | -------------------------------------------------------------------------------- /data/fields/zonalRast.tfw: -------------------------------------------------------------------------------- 1 | 1.0000000000 2 | 0.0000000000 3 | 0.0000000000 4 | -1.0000000000 5 | 711744.0000000000 6 | 3910107.0945999995 7 | -------------------------------------------------------------------------------- /data/fields/zonalRast.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/fields/zonalRast.tif -------------------------------------------------------------------------------- /data/fields/zonalRast.tif.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NEAREST 5 | 6 | 7 | 8 | 9 | -0.5 10 | 3.5 11 | 4 12 | 1 13 | 0 14 | 0|63832|38705|13074 15 | 16 | 17 | 18 | 1 19 | 3 20 | 1.5609587323006 21 | 0.68735752679393 22 | 1 23 | 1 24 | 25 | 0.472460369640271 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /data/fields/zonalRast.tif.ovr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/fields/zonalRast.tif.ovr -------------------------------------------------------------------------------- /data/fields/zonalRast.tif.vat.dbf: -------------------------------------------------------------------------------- 1 | saWValueN CountF 1 6.38320000000e+004 2 3.87050000000e+004 3 1.30740000000e+004 -------------------------------------------------------------------------------- /data/fields/zonaltable.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/fields/zonaltable.dbf -------------------------------------------------------------------------------- /data/fields/zone.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/fields/zone.tif -------------------------------------------------------------------------------- /data/networks/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Network Data 2 | =================================================== 3 | Abstract: Network data that is used in the Network examples. 4 | 5 | 6 | 7 | Karate club 8 | ----------- 9 | The file karate.gml contains the network of friendships between the 34 10 | members of a karate club at a US university, as described by Wayne Zachary 11 | in 1977. 12 | 13 | ### Files 14 | - `karate.gml` 15 | 16 | ### References 17 | W. W. Zachary, An information flow model for conflict and fission in small groups, Journal of Anthropological Research 33, 452-473 (1977) 18 | 19 | 20 | 21 | UCSB road network 22 | ------------------ 23 | Data taken from Open Streetmap and cleaned in QGis. 24 | 25 | ### Files 26 | - `ucsb.shp/` 27 | 28 | 29 | 30 | Other examples 31 | -------------- 32 | - U.S. Tiger files for roads: ftp://ftp2.census.gov/geo/tiger/TIGER2014/ROADS 33 | - Large collection of GML data, free for scientific use: http://www-personal.umich.edu/~mejn/netdata/ 34 | - https://wiki.gephi.org/index.php/Datasets 35 | -------------------------------------------------------------------------------- /data/networks/ucsb.shp/ucsb.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /data/networks/ucsb.shp/ucsb.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/networks/ucsb.shp/ucsb.dbf -------------------------------------------------------------------------------- /data/networks/ucsb.shp/ucsb.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /data/networks/ucsb.shp/ucsb.qpj: -------------------------------------------------------------------------------- 1 | GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]] 2 | -------------------------------------------------------------------------------- /data/networks/ucsb.shp/ucsb.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/networks/ucsb.shp/ucsb.shp -------------------------------------------------------------------------------- /data/networks/ucsb.shp/ucsb.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/networks/ucsb.shp/ucsb.shx -------------------------------------------------------------------------------- /data/objects/Rooftop.lyr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/Rooftop.lyr -------------------------------------------------------------------------------- /data/objects/Rooftops.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/Rooftops.dbf -------------------------------------------------------------------------------- /data/objects/Rooftops.prj: -------------------------------------------------------------------------------- 1 | PROJCS["NAD_1983_2011_UTM_Zone_10N",GEOGCS["GCS_NAD_1983_2011",DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]],VERTCS["NAVD_1988",VDATUM["North_American_Vertical_Datum_1988"],PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/objects/Rooftops.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/Rooftops.shp -------------------------------------------------------------------------------- /data/objects/Rooftops.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/Rooftops.shx -------------------------------------------------------------------------------- /data/objects/ViablePVArea.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/ViablePVArea.dbf -------------------------------------------------------------------------------- /data/objects/ViablePVArea.prj: -------------------------------------------------------------------------------- 1 | PROJCS["NAD_1983_2011_UTM_Zone_10N",GEOGCS["GCS_NAD_1983_2011",DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/objects/ViablePVArea.sbn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/ViablePVArea.sbn -------------------------------------------------------------------------------- /data/objects/ViablePVArea.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/ViablePVArea.shp -------------------------------------------------------------------------------- /data/objects/ViablePVArea.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/ViablePVArea.shx -------------------------------------------------------------------------------- /data/objects/roads.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/roads.dbf -------------------------------------------------------------------------------- /data/objects/roads.prj: -------------------------------------------------------------------------------- 1 | PROJCS["NAD_1983_2011_UTM_Zone_10N",GEOGCS["GCS_NAD_1983_2011",DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]],VERTCS["NAVD_1988",VDATUM["North_American_Vertical_Datum_1988"],PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/objects/roads.sbn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/roads.sbn -------------------------------------------------------------------------------- /data/objects/roads.sbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/roads.sbx -------------------------------------------------------------------------------- /data/objects/roads.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/roads.shp -------------------------------------------------------------------------------- /data/objects/roads.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/roads.shx -------------------------------------------------------------------------------- /data/objects/rooftops_pv.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/rooftops_pv.dbf -------------------------------------------------------------------------------- /data/objects/rooftops_pv.prj: -------------------------------------------------------------------------------- 1 | PROJCS["NAD_1983_2011_UTM_Zone_10N",GEOGCS["GCS_NAD_1983_2011",DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]],VERTCS["NAVD_1988",VDATUM["North_American_Vertical_Datum_1988"],PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/objects/rooftops_pv.sbn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/rooftops_pv.sbn -------------------------------------------------------------------------------- /data/objects/rooftops_pv.sbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/rooftops_pv.sbx -------------------------------------------------------------------------------- /data/objects/rooftops_pv.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/rooftops_pv.shp -------------------------------------------------------------------------------- /data/objects/rooftops_pv.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/rooftops_pv.shx -------------------------------------------------------------------------------- /data/objects/tmp/roofs_aboveMinInsol.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/tmp/roofs_aboveMinInsol.dbf -------------------------------------------------------------------------------- /data/objects/tmp/roofs_aboveMinInsol.prj: -------------------------------------------------------------------------------- 1 | PROJCS["NAD_1983_2011_UTM_Zone_10N",GEOGCS["GCS_NAD_1983_2011",DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]],VERTCS["NAVD_1988",VDATUM["North_American_Vertical_Datum_1988"],PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/objects/tmp/roofs_aboveMinInsol.sbn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/tmp/roofs_aboveMinInsol.sbn -------------------------------------------------------------------------------- /data/objects/tmp/roofs_aboveMinInsol.sbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/tmp/roofs_aboveMinInsol.sbx -------------------------------------------------------------------------------- /data/objects/tmp/roofs_aboveMinInsol.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/tmp/roofs_aboveMinInsol.shp -------------------------------------------------------------------------------- /data/objects/tmp/roofs_aboveMinInsol.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/tmp/roofs_aboveMinInsol.shx -------------------------------------------------------------------------------- /data/objects/tmp/roofs_within50mroads.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/tmp/roofs_within50mroads.dbf -------------------------------------------------------------------------------- /data/objects/tmp/roofs_within50mroads.prj: -------------------------------------------------------------------------------- 1 | PROJCS["NAD_1983_2011_UTM_Zone_10N",GEOGCS["GCS_NAD_1983_2011",DATUM["D_NAD_1983_2011",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]],VERTCS["NAVD_1988",VDATUM["North_American_Vertical_Datum_1988"],PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/objects/tmp/roofs_within50mroads.sbn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/tmp/roofs_within50mroads.sbn -------------------------------------------------------------------------------- /data/objects/tmp/roofs_within50mroads.sbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/tmp/roofs_within50mroads.sbx -------------------------------------------------------------------------------- /data/objects/tmp/roofs_within50mroads.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/tmp/roofs_within50mroads.shp -------------------------------------------------------------------------------- /data/objects/tmp/roofs_within50mroads.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spatial-ucsb/ConceptsOfSpatialInformation/73d54a37ced14bc5ecb064f9d1ab8b1af8cd3c5a/data/objects/tmp/roofs_within50mroads.shx -------------------------------------------------------------------------------- /extras/CoreConceptsHs Backup/.gitignore: -------------------------------------------------------------------------------- 1 | # https://github.com/github/gitignore/blob/master/Haskell.gitignore 2 | dist 3 | cabal-dev 4 | *.o 5 | *.hi 6 | *.chi 7 | *.chs.h 8 | *.dyn_o 9 | *.dyn_hi 10 | .virtualenv 11 | .hpc 12 | .hsenv 13 | .cabal-sandbox/ 14 | cabal.sandbox.config 15 | *.prof 16 | *.aux 17 | *.hp 18 | -------------------------------------------------------------------------------- /extras/CoreConceptsHs Backup/Event.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | {-# LANGUAGE FlexibleInstances #-} 3 | 4 | -- the content concept of an event 5 | -- core questions: when did this event happen? what happened before? what participants does the event have? 6 | -- events are instantiated process portions with fields, objects, and networks as participants 7 | -- an event collection is an event (in analogy to a feature collection being a feature) 8 | -- (c) Werner Kuhn 9 | -- latest change: Feb 6, 2016 10 | -- To Do 11 | -- compute event outcomes: central, but how to specify? do simple examples 12 | 13 | module Event where 14 | 15 | import Time 16 | 17 | -- the class of all event types 18 | -- Eq captures identity 19 | -- events are bounded in time, but do not need an explicit boundary 20 | class Eq (event time) => EVENTS event time where 21 | bounds :: event time -> Interval time 22 | 23 | data InstantEvent time = InstantEvent (Instant time) deriving (Eq, Show) 24 | 25 | instance (Eq time, Ord time) => EVENTS InstantEvent time where 26 | bounds (InstantEvent (Instant t1 trs1)) = Interval (Instant t1 trs1) (Instant t1 trs1) 27 | 28 | -- TESTS 29 | ie1, ie2 :: InstantEvent Int 30 | ie1 = InstantEvent i1 31 | ie2 = InstantEvent i2 32 | et1 = bounds ie1 -------------------------------------------------------------------------------- /extras/CoreConceptsHs Backup/Field.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | {-# LANGUAGE FunctionalDependencies #-} 3 | 4 | -- the content concept of a field 5 | -- core question: what is the value of an attribute at a position and an instant? 6 | -- all fields are spatio-temporal, defined for a location and time 7 | -- the positions can be georeferenced or not (allowing, for example, for non-georeferenced images) 8 | -- field models can be raster or vector (then with an interpolation function) 9 | -- (c) Werner Kuhn 10 | -- latest change: Feb 6, 2016 11 | -- TO DO 12 | -- do a vector field model and find out how to abstract over raster and vector representations of the field function 13 | -- generalize map algebra operations to a single operation on multiple fields, taking a function as input (TH idea), signature [value]->value? 14 | -- look at the toolbox of QGIS whether it does all map algebra with one underlying operator! 15 | -- import qualified Data.Array.Repa as Repa (to implement fields with more computations, richer index types, and IO formats) 16 | 17 | module Field where 18 | 19 | import Location 20 | import Time 21 | import Theme 22 | import Data.Array 23 | 24 | -- the class of all field types 25 | -- fields have a field function as well as a location and a time over which they are defined 26 | -- functional dependencies avoid type ambiguities (some of them at runtime!) 27 | class (LOCATIONS location coord, TIMES time scale) => FIELDS field location coord time scale | field -> location coord, field -> time scale where 28 | domain :: field -> (location coord, time scale) -- the location and the time over which the field is defined 29 | valueAt :: field -> Position coord -> Instant scale -> Value -- needs to check if position and instant are within domain and period 30 | {- insideOf, outsideOf :: field -> object -> field -- cutting or masking the domain by an object 31 | during, except :: field -> time scale -> field -- cutting or masking the period 32 | local :: [field position value] -> ([value] -> value') -> field position value' object event 33 | focal :: field position value object event -> (neighborhood -> value') -> field position value' object event -- with a kernel function to compute the new values based on the values in the neighborhood of the position 34 | zonal :: field position value object event -> (zones -> value') -> field position value' object event -- map algebra's zonal operations, with a function to compute the new values based on zones containing the positions 35 | -} 36 | 37 | -- a raster model of a 2d spatial field function 38 | type FieldFunction2d = Array (Int, Int) Value 39 | a2 :: FieldFunction2d 40 | a2 = array (p11t, p22t) [(p11t, Boolean True), (p21t, Boolean False), (p12t, Boolean True), (p22t,Boolean False)] 41 | 42 | -- instantaneous 2d raster fields 43 | data RasterField2d = RasterField2d FieldFunction2d (MBR Int) (Instant Int) 44 | rf1 = RasterField2d a2 mbr1 i1 45 | 46 | instance FIELDS RasterField2d MBR Int Instant Int where 47 | domain (RasterField2d a m i) = (m, i) 48 | valueAt (RasterField2d a m i) p t 49 | | not (positionIn p m) = error "position outside field domain" 50 | | not (contains i t) = error "instant outside field domain" 51 | | otherwise = a ! (pos2Tup2 p) 52 | 53 | -- TESTS 54 | ft1 = domain rf1 55 | ft2 = valueAt rf1 p11 i1 56 | -------------------------------------------------------------------------------- /extras/CoreConceptsHs Backup/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Core Concepts Haskell library 3 | # 4 | # ====== VARIABLES ====== 5 | 6 | # ====== TARGETS ====== 7 | all: 8 | @echo "Select an option."; 9 | @cat Makefile; 10 | @echo "\n"; 11 | 12 | clean: 13 | @rm -rf *.hi **/*.hi *.o **/*.o; 14 | 15 | test-events: clean 16 | @echo "No examples and no tests for events yet." 17 | 18 | test-fields: clean 19 | @echo "No examples and no tests for fields yet." 20 | 21 | test-locations: clean 22 | @echo "No examples and no tests for locations yet." 23 | 24 | test-networks: clean 25 | @echo "No tests for networks yet. Have a look at the examples." 26 | 27 | test-objects: clean 28 | @echo "No examples and no tests for objects yet." 29 | 30 | test-all: test-events test-fields test-locations test-networks test-objects 31 | 32 | example-events: clean 33 | @echo "No examples and no tests for events yet." 34 | 35 | example-fields: clean 36 | @echo "No examples and no tests for fields yet." 37 | 38 | example-locations: clean 39 | @echo "No examples and no tests for locations yet." 40 | 41 | example-networks: clean 42 | runhaskell NetworkExamples.hs 43 | 44 | example-objects: clean 45 | @echo "No examples for objects yet. Have a look at the tests." 46 | 47 | example-all: example-events example-fields example-locations example-networks example-objects 48 | 49 | install-dependencies: 50 | # for Linux/Mac 51 | cabal install fgl; 52 | -------------------------------------------------------------------------------- /extras/CoreConceptsHs Backup/Network.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | {-# LANGUAGE TypeSynonymInstances #-} 3 | {-# LANGUAGE FlexibleInstances #-} 4 | {-# LANGUAGE FunctionalDependencies #-} 5 | 6 | -- core concept: network 7 | -- core question: are two nodes connected? what is the shortest path between them? 8 | -- how to bring in PATH and LINK from earlier specs? 9 | -- (c) Werner Kuhn, Michel Zimmer 10 | -- latest change: Mar 2, 2015 11 | 12 | module Network where 13 | 14 | -- the class of all network types 15 | -- both nodes and edges can be labeled 16 | class NETWORK network node edge | network -> node, network -> edge where 17 | nodes :: network -> [node] 18 | edges :: network -> [edge] 19 | addNode :: network -> node -> network 20 | addEdge :: network -> edge -> network -- link existing nodes 21 | degree :: network -> node -> Int -- number of edges to other nodes 22 | connected :: network -> node -> node -> Bool -- can the second node be reached from the first? 23 | shortestPath :: network -> node -> node -> [edge] 24 | distance :: network -> node -> node -> Int -- length of the shortest path as number of nodes 25 | breadthFirst :: network -> node -> Int -> [node] -- all nodes at distance Int from a node 26 | 27 | -- Graph representation in FGL 28 | -- also, use FGL to determine core queries 29 | -------------------------------------------------------------------------------- /extras/CoreConceptsHs Backup/NetworkImpl.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE FlexibleContexts #-} 2 | {-# LANGUAGE FlexibleInstances #-} 3 | {-# LANGUAGE MultiParamTypeClasses #-} 4 | {-# LANGUAGE TypeSynonymInstances #-} 5 | 6 | -- implementation for core concept: network 7 | -- (c) Michel Zimmer 8 | -- latest change: Mar 11, 2015 9 | 10 | module NetworkImpl where 11 | 12 | import Network 13 | import Data.List 14 | import Data.Maybe 15 | import Data.Graph.Inductive.Graph 16 | import Data.Graph.Inductive.PatriciaTree 17 | import Data.Graph.Inductive.Query.BFS 18 | 19 | type Node = Data.Graph.Inductive.Graph.Node 20 | type Weight = Int 21 | type Edge = Data.Graph.Inductive.Graph.LEdge Weight 22 | type CCGraph = Gr () Weight 23 | 24 | instance NETWORK CCGraph NetworkImpl.Node NetworkImpl.Edge where 25 | nodes = map fst . labNodes 26 | edges = labEdges 27 | addNode graph node = insNode (node, ()) graph 28 | addEdge = flip $ insEdge 29 | degree = deg 30 | connected graph a b = 0 /= distance graph a b 31 | shortestPath graph a b = map label edges 32 | where 33 | label :: Data.Graph.Inductive.Graph.Edge -> NetworkImpl.Edge 34 | label (a, b) = (a, b, 1) 35 | edges :: [Data.Graph.Inductive.Graph.Edge] 36 | edges = zip path $ tail path 37 | path :: [NetworkImpl.Node] 38 | path = esp a b graph 39 | distance graph a b = length $ shortestPath graph a b 40 | breadthFirst graph node distance = map fst $ filter select $ level node graph 41 | where 42 | select :: (NetworkImpl.Node, Int) -> Bool 43 | select (_, d) = d <= distance 44 | 45 | mkGraph :: [NetworkImpl.Node] -> [NetworkImpl.Edge] -> CCGraph 46 | mkGraph nodes ledges = Data.Graph.Inductive.Graph.mkGraph (map label nodes) ledges 47 | where 48 | label :: NetworkImpl.Node -> LNode () 49 | label node = (node, ()) 50 | -------------------------------------------------------------------------------- /extras/CoreConceptsHs Backup/Object.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | {-# LANGUAGE FlexibleInstances #-} 3 | 4 | -- the content concept of an object 5 | -- core questions: where is this object? is it the same as that object? 6 | -- collections of objects are objects too (consistent with feature collections being features in OGC) 7 | -- objects have state, queried through their spatial and thematic properties and relations 8 | -- (c) Werner Kuhn 9 | -- latest change: Feb 6, 2016 10 | 11 | module Object where 12 | 13 | import Location 14 | 15 | -- the class of all object types 16 | -- Eq captures identity; each object type has its own identity criterion (which iD can use to generate an Id if needed) 17 | -- all objects are bounded (though they may not have a boundary, nor a centroid or any other geometry!) 18 | -- is mbr a good model? it is a bounding box, after all 19 | -- all other properties and relations to be defined on concrete object types (none of them are generic) 20 | class Eq (object coord) => OBJECTS object coord where 21 | mbr :: object coord -> MBR coord 22 | 23 | -- object IDs (for types that need one) 24 | newtype Id = Id Int deriving (Eq, Show) 25 | 26 | -- points of interest 27 | data POI coord = Poi Id (Position coord) deriving Show 28 | instance Eq (POI coord) where 29 | Poi i p == Poi j q = i == j 30 | instance OBJECTS POI coord where 31 | mbr (Poi i p) = MBR p p 32 | 33 | -- box objects 34 | data Box coord = Box (MBR coord) deriving Show 35 | instance Eq coord => Eq (Box coord) where 36 | Box mbr1 == Box mbr2 = mbr1 == mbr2 37 | instance Eq coord => OBJECTS Box coord where 38 | mbr (Box mbr) = mbr 39 | 40 | -- tests 41 | poi1 = Poi (Id 1) p11 42 | poi2 = Poi (Id 2) p22 43 | ot1 = mbr poi1 44 | box1 = Box mbr1 45 | box2 = Box mbr2 -------------------------------------------------------------------------------- /extras/CoreConceptsHs Backup/README.md: -------------------------------------------------------------------------------- 1 | Core Concepts of Spatial Information - Haskell 2 | ============================================== 3 | 4 | Abstract: Specifications and implementation of the core concepts in Haskell. 5 | 6 | See the [Readme](../README.md) in the parent directory for more information about the core concepts itself. 7 | 8 | Right now the implementation is in a proof of concept state and should not be considered stable for a production environment. 9 | 10 | Contents 11 | ---------------------- 12 | 13 | - `Event.hs`: Specifications of events. 14 | - `Field.hs`: Specifications of fields. 15 | - `Location.hs`: Specifications of locations. 16 | - `Makefile`: Common commands for unix platforms. 17 | - `NetworkExamples.hs`: Examples for networks. 18 | - `Network.hs`: Specifications of networks. 19 | - `NetworkImpl.hs`: Implementations of networks. 20 | - `Object.hs`: Specifications of objects. 21 | 22 | How to test the code and run the examples 23 | ----------------------------------------- 24 | 25 | ### Unix/Linux platforms 26 | To run the Unit Tests execute: `make test-all` 27 | 28 | To run the examples execute: `make example-all` 29 | 30 | Dependencies 31 | ---------------------- 32 | - [FGL](https://hackage.haskell.org/package/fgl) (Version: latest*) 33 | 34 | \* Most recent stable release on hackage 35 | 36 | ### Unix/Linux platforms 37 | To install the dependencies execute: `make install-dependencies` 38 | -------------------------------------------------------------------------------- /extras/CoreConceptsHs Backup/Theme.hs: -------------------------------------------------------------------------------- 1 | -- the base concept of a theme 2 | -- defining non-spatial and non-temporal thematic (a.k.a. attribute) values and operations on them 3 | -- (c) Werner Kuhn 4 | -- latest change: Jan 15, 2016 5 | 6 | module Theme where 7 | 8 | -- thematic values 9 | -- essentially measurement scales 10 | -- modeled as a sum type (until we need more) 11 | -- any generic behavior across scales? probably just equality (almost by definition) 12 | data Value = Boolean Bool | Nominal String | Ordinal String | Interval Int | Ratio Float deriving (Eq, Show) 13 | 14 | -------------------------------------------------------------------------------- /extras/CoreConceptsHs Backup/Time.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | 3 | -- the base concept of time 4 | -- temporal properties and relations 5 | -- (c) Werner Kuhn 6 | -- latest change: February 5, 2016 7 | -- TO DO 8 | -- check OGC terminology for time 9 | -- what about cyclic time? 10 | 11 | module Time where 12 | 13 | -- times are values of temporal attributes (temporal analogues to locations, not to metric geometries) 14 | -- they are parameterized in their time scale, which has to be at least ordinal (e.g., geological eras) 15 | -- their behavior is captured by Allen's relations (add more of them as needed) 16 | class Ord scale => TIMES time scale where 17 | instantIn :: Instant scale -> time scale -> Bool 18 | precedes :: time scale -> time scale -> Bool 19 | contains :: time scale -> time scale -> Bool 20 | separation :: Num scale => time scale -> time scale -> scale -- a distance on the time scale (not an interval) 21 | 22 | -- temporal reference systems 23 | -- based on https://github.com/52North/PostTIME/wiki/List-of-available-reference-systems 24 | data TRS = CAL Int | TCS Int | ORD Int deriving (Eq, Show) 25 | errorTRS = "different temporal reference systems" 26 | 27 | -- instants 28 | data Instant scale = Instant scale TRS deriving (Eq, Show) 29 | 30 | instance TIMES Instant Int where 31 | instantIn (Instant t1 trs1) (Instant t2 trs2) = if (trs1==trs2) then (t1==t2) else error errorTRS 32 | contains (Instant t1 trs1) (Instant t2 trs2) = if (trs1==trs2) then (t1==t2) else error errorTRS 33 | precedes (Instant t1 trs1) (Instant t2 trs2) = if (trs1==trs2) then (t1