“Yeah, these measurements are all significantly shorter than the official border lengths, but in the right order…”
select round(a.shape.ST_SRID(4326).ST_Area('kilometer')) as "area"
from "TESTSGEO"."cntry00" a
where a.CNTRY_NAME like 'Germany';
--Result in square kilometers is 357,221
hxeadm@hxehost:/usr/sap/HXE/HDB90/work> mkdir osm_coastlines
hxeadm@hxehost:/usr/sap/HXE/HDB90/work> cd osm_coastlines/
hxeadm@hxehost:/usr/sap/HXE/HDB90/work/osm_coastlines> wget http://data.openstreetmapdata.com/coastlines-generalized-3857.zip
hxeadm@hxehost:/usr/sap/HXE/HDB90/work/osm_coastlines> unzip coastlines-generalized-3857.zip
hxeadm@hxehost:/usr/sap/HXE/HDB90/work/osm_coastlines> cd coastlines-generalized-3857/
hxeadm@hxehost:/usr/sap/HXE/HDB90/work/osm_coastlines/coastlines-generalized-3857> ls -l *.shp
-rw-r--r-- 1 hxeadm sapsys 172884 Mar 26 11:02 coastlines_z1.shp
-rw-r--r-- 1 hxeadm sapsys 329740 Mar 26 11:02 coastlines_z2.shp
-rw-r--r-- 1 hxeadm sapsys 868932 Mar 26 11:02 coastlines_z3.shp
-rw-r--r-- 1 hxeadm sapsys 2051324 Mar 26 11:02 coastlines_z4.shp
-rw-r--r-- 1 hxeadm sapsys 4842884 Mar 26 11:02 coastlines_z5.shp
-rw-r--r-- 1 hxeadm sapsys 10507132 Mar 26 11:02 coastlines_z6.shp
-rw-r--r-- 1 hxeadm sapsys 19768956 Mar 26 11:02 coastlines_z7.shp
-rw-r--r-- 1 hxeadm sapsys 46651260 Mar 26 11:02 coastlines_z8.shp
z8
zoom should contains much more details comparing to previous files."PUBLIC"."ST_SPATIAL_REFERENCE_SYSTEMS"
.--Create EPSG:3857 SRS
CREATE SPATIAL REFERENCE SYSTEM "WGS 84 / Pseudo-Mercator"
IDENTIFIED BY 3857
DEFINITION 'PROJCS["WGS 84 / Pseudo-Mercator",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"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"]]'
ORGANIZATION "EPSG" IDENTIFIED BY 3857
TRANSFORM DEFINITION '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs'
TYPE PLANAR
COORDINATE X BETWEEN -20037508.342789248 AND 20037508.342789248
COORDINATE Y BETWEEN -20048966.104014635 AND 20048966.104014624
TOLERANCE DEFAULT
SNAP TO GRID DEFAULT
POLYGON FORMAT 'EvenOdd' STORAGE FORMAT 'Internal';
--Now load selected files
IMPORT "TESTSGEO"."coastlines_z1"
AS SHAPEFILE
FROM '/usr/sap/HXE/HDB90/work/osm_coastlines/coastlines-generalized-3857/coastlines_z1'
WITH REPLACE SRID 3857 THREADS 4;
IMPORT "TESTSGEO"."coastlines_z4"
AS SHAPEFILE
FROM '/usr/sap/HXE/HDB90/work/osm_coastlines/coastlines-generalized-3857/coastlines_z4'
WITH REPLACE SRID 3857 THREADS 4;
IMPORT "TESTSGEO"."coastlines_z8"
AS SHAPEFILE
FROM '/usr/sap/HXE/HDB90/work/osm_coastlines/coastlines-generalized-3857/coastlines_z8'
WITH REPLACE SRID 3857 THREADS 4;
POLYGON ((-27 63,-11 63,-11 67,-27 67,-27 63))
. Once again, remember about transformations between SRS 3857 used to store geographies in coastlines
tables, and SRS 4326 (GPS coordinates) used to define the bounding box.select ST_UnionAggr("SHAPE").ST_Transform(4326).ST_asSVG()
from "TESTSGEO"."coastlines_z1"
where
"SHAPE".ST_CoveredBy(new ST_Polygon('POLYGON ((-27 63,-11 63,-11 67,-27 67,-27 63))',4326).ST_Transform(3857))=1;
select ST_UnionAggr("SHAPE").ST_Transform(4326).ST_asSVG()
from "TESTSGEO"."coastlines_z4"
where
"SHAPE".ST_CoveredBy(new ST_Polygon('POLYGON ((-27 63,-11 63,-11 67,-27 67,-27 63))',4326).ST_Transform(3857))=1;
select ST_UnionAggr("SHAPE").ST_Transform(4326).ST_asSVG()
from "TESTSGEO"."coastlines_z8"
where
"SHAPE".ST_CoveredBy(new ST_Polygon('POLYGON ((-27 63,-11 63,-11 67,-27 67,-27 63))',4326).ST_Transform(3857))=1;
z1
, red for z4
, and green for z8
.select round(ST_UnionAggr("SHAPE").ST_Transform(4326).ST_length('kilometer'))
from "TESTSGEO"."coastlines_z1"
where
"SHAPE".ST_CoveredBy(new ST_Polygon('POLYGON ((-27 63,-11 63,-11 67,-27 67,-27 63))',4326).ST_Transform(3857))=1;
--The result is 1329
select round(ST_UnionAggr("SHAPE").ST_Transform(4326).ST_length('kilometer'))
from "TESTSGEO"."coastlines_z4"
where
"SHAPE".ST_CoveredBy(new ST_Polygon('POLYGON ((-27 63,-11 63,-11 67,-27 67,-27 63))',4326).ST_Transform(3857))=1;
--The result is 2712
select round(ST_UnionAggr("SHAPE").ST_Transform(4326).ST_length('kilometer'))
from "TESTSGEO"."coastlines_z8"
where
"SHAPE".ST_CoveredBy(new ST_Polygon('POLYGON ((-27 63,-11 63,-11 67,-27 67,-27 63))',4326).ST_Transform(3857))=1;
--The result is 5001
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
20 | |
10 | |
9 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 |