Spatial Database
-
Upload
gianni-gorgoglione -
Category
Documents
-
view
4 -
download
0
description
Transcript of Spatial Database
Spatial Database example SQL/POSTGISGianni Gorgoglione
Spatial databases
PART 1
1. Abstract data type is an abstract data structure that consists of many behaviors. This data type is built by operations and constrains that affect this class. The aim of abstract data type is to classify and describe different programming structures. Basically, ADT is necessary to create an abstract class for different objects that share same functions or attributes of one geometrical class.
2. Objects: Lines_ADT, (curves, straight lines, ziz-zag lines) Operation: geometry (dimension, length, intersection,buffer)Objects: Polygons_ADT (rectagles, square, etc…) Operation: geometry (union, intersection, overlaps)
3. SELECT student.name, student.familyname ,courses.name, CourseResults.gradeFROM Student, CourseResults, CoursesWHERE course.name= ‘GIS-algorithms’ AND grade = 10
PART 2
1. SELECT * FROM citiesSELECT * FROM countriesSELECT * FROM rivers
the_geom
2. SELECT cities.city_name FROM citiesWHERE cntry_name='Sweden'
1
Spatial Database example SQL/POSTGISGianni Gorgoglione
3. Is a method that returns value TRUE if there are not anomalous points as self intersection or self tangency.
SELECT * from rivers
WHERE NOT issimple(the_geom)
Number of matching posts: 20
The river on the right side has a self -intersection
4. SELECT rivers.name,rivers.the_geomFROM rivers , countries WHERE INTERSECTS(rivers.the_geom, countries.the_geom)='TRUE'AND countries.cntry_name='Switzerland' GROUP BY rivers.name,rivers.the_geom
5. a. EQUAL functions will return identical geometry for x and y coordinates b. SELECT DISTINCT rivers.name,length
FROM rivers
c. SELECT DISTINCT rivers.name,lengthFROM rivers WHERE rivers.name='Thames'
Thames 245709.5
SELECT ST_LENGTH(rivers.the_geom),rivers.nameFROM rivers WHERE rivers.name='Thames'1- 245709.494366365
2
Spatial Database example SQL/POSTGISGianni Gorgoglione
Yes, they look identical
d. SELECT MAX(length)FROM riversLongest river 761227.430000000051223
6. SELECT ST_Distance(cities.the_geom, rivers.the_geom)FROM cities, riversWHERE city_name='London' AND rivers.name='Thames'
The distance between London and Thames river is 3857.38
The command St_Distance calculates the distance between two objects by taking the minimum distance of the two geometries. The calculation might take only into account a Cartesian space and not a Sphere projection.
However, it is important to define the points of interest necessary to decide where the start and end point are located in order to calculate the distance. The main reason of this importance is represented by the fact that simply Thames river crosses London. Thus, it is important to understand how London city is represented in City´s geometry as well the rivers´ one. However, in the end, it seems to be wrong all the calculation for the reason explained above-mentioned.
7. SELECT c1.cntry_nameFROM countries AS c1, countries AS c2WHERE ST_Touches(c1.the_geom, c2.the_geom)='1'AND c2.cntry_name='Sweden'
3