postgis学习

postgis学习
#create table gtest(id serial);
#select AddGeometryColumn('','gtest','geom',4326,'LINESTRING',2);


# INSERT INTO gtest (ID, NAME, GEOM)
VALUES (
   1,
   ’First Geometry’,
   GeomFromText(’LINESTRING(2 3,4 5,6 5,7 8)’, -1)
);


# select astext(geom) as geom from gtest;
              geom              
---------------------------------
 LINESTRING(2 3,4 5)
 LINESTRING(2 3,4 5,5 6)
 LINESTRING(2 3,4 5,5 6,3 5)
 LINESTRING(2 3,4 5,5 6,3 5,1 6)
(4 rows)

# create index idx_geom on gtest using GIST(geom);
CREATE INDEX

# select asbinary(geom) as geom from gtest;
                                                                                                                                                                  geom                                                                                                                                                                 
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 \001\002\000\000\000\002\000\000\000\000\000\000\000\000\000\000@\000\000\000\000\000\000\010@\000\000\000\000\000\000\020@\000\000\000\000\000\000\024@
 \001\002\000\000\000\003\000\000\000\000\000\000\000\000\000\000@\000\000\000\000\000\000\010@\000\000\000\000\000\000\020@\000\000\000\000\000\000\024@\000\000\000\000\000\000\024@\000\000\000\000\000\000\030@
 \001\002\000\000\000\004\000\000\000\000\000\000\000\000\000\000@\000\000\000\000\000\000\010@\000\000\000\000\000\000\020@\000\000\000\000\000\000\024@\000\000\000\000\000\000\024@\000\000\000\000\000\000\030@\000\000\000\000\000\000\010@\000\000\000\000\000\000\024@
 \001\002\000\000\000\005\000\000\000\000\000\000\000\000\000\000@\000\000\000\000\000\000\010@\000\000\000\000\000\000\020@\000\000\000\000\000\000\024@\000\000\000\000\000\000\024@\000\000\000\000\000\000\030@\000\000\000\000\000\000\010@\000\000\000\000\000\000\024@\000\000\000\000\000\000\360?\000\000\000\000\000\000\030@
(4 rows)

# select GeomFromText('POINT(116.8839 36.88299)',900913);
                    geomfromtext                   
----------------------------------------------------
 010100002031BF0D00CD3B4ED191385D40F758FAD005714240
(1 row)


# select asEWKB(geom) as geom from gtest;
                                                                                                                                                                        geom                                                                                                                                                                        
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 \001\002\000\000 \346\020\000\000\002\000\000\000\000\000\000\000\000\000\000@\000\000\000\000\000\000\010@\000\000\000\000\000\000\020@\000\000\000\000\000\000\024@
 \001\002\000\000 \346\020\000\000\003\000\000\000\000\000\000\000\000\000\000@\000\000\000\000\000\000\010@\000\000\000\000\000\000\020@\000\000\000\000\000\000\024@\000\000\000\000\000\000\024@\000\000\000\000\000\000\030@
 \001\002\000\000 \346\020\000\000\004\000\000\000\000\000\000\000\000\000\000@\000\000\000\000\000\000\010@\000\000\000\000\000\000\020@\000\000\000\000\000\000\024@\000\000\000\000\000\000\024@\000\000\000\000\000\000\030@\000\000\000\000\000\000\010@\000\000\000\000\000\000\024@
 \001\002\000\000 \346\020\000\000\005\000\000\000\000\000\000\000\000\000\000@\000\000\000\000\000\000\010@\000\000\000\000\000\000\020@\000\000\000\000\000\000\024@\000\000\000\000\000\000\024@\000\000\000\000\000\000\030@\000\000\000\000\000\000\010@\000\000\000\000\000\000\024@\000\000\000\000\000\000\360?\000\000\000\000\000\000\030@
(4 rows)

# select asEWKT(geom) as geom from gtest;
                   geom                   
-------------------------------------------
 SRID=4326;LINESTRING(2 3,4 5)
 SRID=4326;LINESTRING(2 3,4 5,5 6)
 SRID=4326;LINESTRING(2 3,4 5,5 6,3 5)
 SRID=4326;LINESTRING(2 3,4 5,5 6,3 5,1 6)
(4 rows)

# select GeomFromEWKT('SRID=4326;POINT(119.8782 36.29288)');
                    geomfromewkt                   
----------------------------------------------------
 0101000020E610000039D6C56D34F85D4084D382177D254240
(1 row)

# select GeomFromEWKT('SRID=900913;POINT(119.8782 36.29288)');
                    geomfromewkt                   
----------------------------------------------------
 010100002031BF0D0039D6C56D34F85D4084D382177D254240
(1 row)


# select 'SRID=4326;POINT(119.28983 36.99289)'::geometry;
                      geometry                     
----------------------------------------------------
 0101000020E610000094D920938CD25D404243FF04177F4240
(1 row)

# select 'SRID=900913;POINT(119.28983 36.99289)'::geometry;
                      geometry                     
----------------------------------------------------
 010100002031BF0D0094D920938CD25D404243FF04177F4240
(1 row)






|----------------------------------------------------------------------------------------|
                           版权声明  版权所有 @zhyiwww
            引用请注明来源 http://www.blogjava.net/zhyiwww   
|----------------------------------------------------------------------------------------|

你可能感兴趣的:(postgis学习)