Andrea Peri | 1 May 2010 14:26
Picon

Establish versus of a line

Hi Nico,

Many thanks, I think this is the right way. :)

But there is some trouble :(

I will try with this code:

create and fill two tale (polygon and linestrings)

drop table if exists _test_mpoly;
delete from geometry_columns where f_table_schema='public' and f_table_name='_test_mpoly';
create table _test_mpoly (id serial primary key);
SELECT AddGeometryColumn('_test_mpoly', 'geom', 3003, 'MULTIPOLYGON', 2);
insert into _test_mpoly (geom) values ( ST_GeomFromText('MULTIPOLYGON( ((4 8, 7 9, 10 7, 9 4, 6 1, 3 2, 2 3, 1 6, 4 8)))',3003 ));

drop table if exists _test_line;
delete from geometry_columns where f_table_schema='public' and f_table_name='_test_line';
create table _test_line (id serial primary key,verso integer);

SELECT AddGeometryColumn('_test_line', 'geom', 3003, 'LINESTRING', 2);
insert into _test_line (geom) values ( ST_GeomFromText('LINESTRING(2 3, 3 2, 6 1)',3003 )); //
insert into _test_line (geom) values ( ST_GeomFromText('LINESTRING(6 1, 3 2, 2 3)',3003 )); // opposite to theb other line

As notable I insert in the linestring table 2 lines with opposite versus.

After this I try next sql select with the ST_OrderingEquals function.

select
a.id as id,
case
when ST_OrderingEquals(a.geom,c.geom)=true then 1
else 0
end as versus
from
public._test_line as a,
(select ST_Boundary(b.geom) as geom from public._test_mpoly as b) as c
where
ST_Intersects(a.geom,c.geom)=true

The results I will hope was
0 (first linestring is opposite versus to boundary polygon)
1 (second linestring is same versus to boundary polygon)


But the received results are
0
0

:(

I don't understand what is wrongly.


Regards, Andrea.



>Ok, so maybe you could rebuild polygons from the linestrings and test
>these polygons ?
>
>select st_orderingEquals(
> st_makepolygon(geom),
> st_forceRHR(st_makepolygon(geom))) from
>
>(select geometryFromText('LINESTRING (0 0, 1 0, 1 1, 0 1, 0 0)', -1) as geom
>union
>select geometryFromText('LINESTRING (2 2, 2 3, 3 3, 3 2, 2 2)', -1) as
>geom) as foo
>;
>
>Nico


--
-----------------
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-----------------

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Andrea Peri | 2 May 2010 11:27
Picon

Establish versus of a line

Hi,

I do some test.

I notice that the ST_OrderingEquals

return true only when two lines are perfectly identical (same sequence vertex too).

For example:

Select ST_OrderingEquals(
    ST_GeomFromText('LINESTRING(2 3, 3 2, 6 1)',3003 ),ST_GeomFromText('LINESTRING(2 3, 3 2, 6 1)',3003 )
)

But if I add a single vertex to one of lines it return false.
Select ST_OrderingEquals(
    ST_GeomFromText('LINESTRING(2 3, 3 2, 6 1, 8 9)',3003 ),ST_GeomFromText('LINESTRING(2 3, 3 2, 6 1)',3003 )
)

So it is not useful to detect the versus of lines because
the linestring of the line table is not sure they are perfectly identical to the definition of the boundary of polygons.
The boundary of polygons are always closed lines.
Instead the same closed arc may be require more lines of the line table.

More again:
even supposing the lines-table elements was closed like the boundary of polygons the ST_OderingEqual require they are
first vertex identical.

So this case of two lines identical, and same versus but different starting vertex, return false.

Select ST_OrderingEquals(
    ST_GeomFromText('LINESTRING(2 3, 3 2, 6 1, 8 9, 2 3)',3003 ),ST_GeomFromText('LINESTRING(3 2, 6 1, 8 9, 2 3, 3 2)',3003 )
)

Regards,


--
-----------------
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-----------------

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Jorge Arevalo | 2 May 2010 13:31

2 versions of PostGIS at same time for developing. How?

Hello,

I'd like to test the code I'm developing (WKT Raster) with 2 versions
of PostGIS: The stable branch (1.4 based) and the development branch.
What would be the best way to do this? 2 instances of PostgreSQL
running? spatially enable 2 postgresql databases with different
versions of postgis? Is it possible?

Thanks in advance, and best regards,
Jorge

----
http://www.gis4free.org/blog
bruce bushby | 2 May 2010 22:46

select "ST_AsSvg" from multiple tables in relation to decimal degree coordinates

Hi


I'm guessing my question is a very common example however I've been struggling (3 days) to find an example that works for me.

I have converted my NMEA gps into decimal degrees:
track=# select lat,long,the_geom from t001;
    lat     |    long     |                      the_geom                     
------------+-------------+----------------------------------------------------
 51.4096    | -0.210978   | 0101000020AD100000647616BD5301CBBF8638D6C56DB44940



Then I have a map of roads which I know has roads all around my coordinates, so I wanted to select "ST_AsSvg" a 1 Kilometre square block around my coordinates, I tried to do this with:

UK=# select ST_AsSvg(the_geom) from minor_rd_polyline where the_geom && SetSRID('BOX3D(51.4095 -0.211098 0,51.4080 -0.211080 0)'::box3d,-1);
 st_assvg
----------
(0 rows)

UK=#

My goal is to "select" from multiple maps (maps/tables were created with shp1pgsql) around given gps coordinates and return as svg.

Any help much appreciated!

Thanks
Bruce




_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Robert Coup | 2 May 2010 23:01
Picon
Gravatar

Re: select "ST_AsSvg" from multiple tables in relation to decimal degree coordinates

Hi Bruce,

On Mon, May 3, 2010 at 8:46 AM, bruce bushby
<bruce.bushby <at> googlemail.com> wrote:
> Then I have a map of roads which I know has roads all around my coordinates,
> so I wanted to select "ST_AsSvg" a 1 Kilometre square block around my
> coordinates, I tried to do this with:
>
> UK=# select ST_AsSvg(the_geom) from minor_rd_polyline where the_geom &&
> SetSRID('BOX3D(51.4095 -0.211098 0,51.4080 -0.211080 0)'::box3d,-1);

It should be
BOX3D(-0.211098 51.4095 0, -0.211080 51.4080 0)

The order of coordinates for anything in postgis is (X, Y[, Z])

Rob :)
Francis Markham | 3 May 2010 08:41
Picon
Picon

line_interpolate_point does not return a point that intersects the line

Hi all,

I think I've got a bit of a problem with snapping points to lines.  I had thought that using line_interpolate_point(..., line_locate_point(...)) would do the trick, but this seems not to be the case:

gis=# SELECT ST_AsText(v.the_geom), ST_SRID(v.the_geom), ST_AsText(r.the_geom), ST_SRID(r.the_geom) FROM road_segments AS r, venues AS v WHERE v.venue_id = 29 AND r.gid = 100982;

                st_astext                 | st_srid |                                    st_astext                                    | st_srid
------------------------------------------+---------+---------------------------------------------------------------------------------+---------
 POINT(415185.606066865 7827721.52951473) |   28353 | LINESTRING(415250.679102704 7827994.85292521,415218.694181662 7827642.44920486) |   28353
(1 row)

gis=# SELECT ST_Intersects(ST_line_interpolate_point(r.the_geom, ST_line_locate_point(r.the_geom, v.the_geom)), r.the_geom) FROM road_segments AS r, venues AS v WHERE v.venue_id = 29 AND r.gid = 100982;

 st_intersects
---------------
 f
(1 row)

gis=# SELECT postgis_full_version();

                                  postgis_full_version                                 
----------------------------------------------------------------------------------------
 POSTGIS="1.4.1" GEOS="3.2.1-CAPI-1.6.1" PROJ="Rel. 4.7.1, 23 September 2009" USE_STATS
(1 row)



Any assistance would be much appreciated.

Thanks,

-Francis Markham

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Mehmet Erkek | 3 May 2010 09:03
Favicon

Converting UTM to lat/lon using Postgis

 

Hi All,

 

I havea a shape file which I imported it to a table called ‘test2’ (using  SRID=4326).  I want to get centroids of geometries in lat/lon.

 

Here is what I run:

 

select   ST_AsText( ST_Transform(centroid(the_geom),4326)) from ult.test2 limit 5;

 

and what I get:

 

POINT(496597.996430787 2774798.21242881)

POINT(496332.629887436 2793339.61534586)

POINT(496302.627327975 2793317.82477318)

POINT(496305.255261594 2793353.29646291)

POINT(496241.538851096 2774826.65593589)

 

 

So far all is fine except coordinates which are not  latitude/longitude

 

My question is : How can I convert/get these coordinates in lat/lon?

 

 

This what I have in my prj file:

 

PROJCS["Dubai Local Transverse Mercator (DLTM)",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",55.33333333333334],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]

 

 

And this is my postgis version: POSTGIS="1.3.6" GEOS="2.2.3-CAPI-1.1.1" PROJ="Rel. 4.7.1, 23 September 2009" USE_STATS

 

I appreciate any help. Thank you.

 

 

-------------------------------------------------------------------

Mehmet ERKEK

www.REIDIN.com

 


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Please Consider the Environment Before Printing This Email
_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Guillaume Sueur | 3 May 2010 09:08
Favicon

Re: Converting UTM to lat/lon using Postgis

Hi,

As you declared your input shapefile to be in 4326 (which is lat/lon), 
Postgis doesn't transform anything in your coordinates when you ask for 
lat/lon.
Try to set the proper SRID for Dubai Local Transverse Mercator using 
SELECT setSRID(the_geom,the_srid) FROM ult.test2;
Note that you may have to drop a constraint forcing your srid to be 4326 
first.

Regards,

Guillaume

On 03/05/2010 09:03, Mehmet Erkek wrote:
> Hi All,
>
> I havea a shape file which I imported it to a table called ‘test2’
> (using SRID=4326). I want to get centroids of geometries in lat/lon.
>
> Here is what I run:
>
> select ST_AsText( ST_Transform(centroid(the_geom),4326)) from ult.test2
> limit 5;
>
> and what I get:
>
> POINT(496597.996430787 2774798.21242881)
>
> POINT(496332.629887436 2793339.61534586)
>
> POINT(496302.627327975 2793317.82477318)
>
> POINT(496305.255261594 2793353.29646291)
>
> POINT(496241.538851096 2774826.65593589)
>
> So far all is fine except coordinates which are not latitude/longitude
>
> *_My question is : How can I convert/get these coordinates in lat/lon?_*
>
> This what I have in my prj file:
>
> PROJCS["Dubai Local Transverse Mercator
> (DLTM)",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",55.33333333333334],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
>
> And this is my postgis version: POSTGIS="1.3.6" GEOS="2.2.3-CAPI-1.1.1"
> PROJ="Rel. 4.7.1, 23 September 2009" USE_STATS
>
> I appreciate any help. Thank you.
>
> -------------------------------------------------------------------
>
> *Mehmet ERKEK***
>
> www.REIDIN.com <http://www.reidin.com/>
>
>
> This message is for the designated recipient only and may contain
> privileged, proprietary, or otherwise private information. If you have
> received it in error, please notify the sender immediately and delete
> the original. Any other use of the email by you is prohibited. Please
> Consider the Environment Before Printing This Email
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users <at> postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Francis Markham | 3 May 2010 09:09
Picon
Gravatar

Re: Converting UTM to lat/lon using Postgis

Hi Mehmet,

When you imported the shapefile, the SRID you are meant to specify is the SRID of the data, not the SRID you want.  Since the data is in Dubai Local TM, the SRID is 3997.  To get the transformation you want, try the following:

select   ST_AsText( ST_Transform(centroid(ST_SetSRID(the_geom, 3997)),4326)) from ult.test2 limit 5;

Hope that helps,

-Francis

On 3 May 2010 17:03, Mehmet Erkek <merkek <at> reidin.com> wrote:

 

Hi All,

 

I havea a shape file which I imported it to a table called ‘test2’ (using  SRID=4326).  I want to get centroids of geometries in lat/lon.

 

Here is what I run:

 

select   ST_AsText( ST_Transform(centroid(the_geom),4326)) from ult.test2 limit 5;

 

and what I get:

 

POINT(496597.996430787 2774798.21242881)

POINT(496332.629887436 2793339.61534586)

POINT(496302.627327975 2793317.82477318)

POINT(496305.255261594 2793353.29646291)

POINT(496241.538851096 2774826.65593589)

 

 

So far all is fine except coordinates which are not  latitude/longitude

 

My question is : How can I convert/get these coordinates in lat/lon?

 

 

This what I have in my prj file:

 

PROJCS["Dubai Local Transverse Mercator (DLTM)",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",55.33333333333334],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]

 

 

And this is my postgis version: POSTGIS="1.3.6" GEOS="2.2.3-CAPI-1.1.1" PROJ="Rel. 4.7.1, 23 September 2009" USE_STATS

 

I appreciate any help. Thank you.

 

 

-------------------------------------------------------------------

Mehmet ERKEK

www.REIDIN.com

 


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Please Consider the Environment Before Printing This Email

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Mehmet Erkek | 3 May 2010 09:50
Favicon

Re: Converting UTM to lat/lon using Postgis

Thank you for the fast answer!

 

Hmm. It looks I don’t have srid 3997 in the DB.

 

 

=# select srid, srtext, proj4text from spatial_ref_sys where srid=3997;

 srid | srtext | proj4text

------+--------+-----------

(0 rows)

 

select srid, srtext, proj4text from spatial_ref_sys where  srtext like '%Dubai%';

 srid | srtext | proj4text

------+--------+-----------

(0 rows)

 

 

Could this be related to my postgis installation?

 

I don’t see this srid in spatial_ref_sys.sql which came with postgis installation either.

 

Any idea how I can fix this?

 

 

-------------------------------------------------------------------

Mehmet ERKEK

www.REIDIN.com

 

From: postgis-users-bounces <at> postgis.refractions.net [mailto:postgis-users-bounces <at> postgis.refractions.net] On Behalf Of Francis Markham
Sent: Monday, May 03, 2010 11:09 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Converting UTM to lat/lon using Postgis

 

Hi Mehmet,

When you imported the shapefile, the SRID you are meant to specify is the SRID of the data, not the SRID you want.  Since the data is in Dubai Local TM, the SRID is 3997.  To get the transformation you want, try the following:

select   ST_AsText( ST_Transform(centroid(ST_SetSRID(the_geom, 3997)),4326)) from ult.test2 limit 5;

Hope that helps,

-Francis

On 3 May 2010 17:03, Mehmet Erkek <merkek <at> reidin.com> wrote:

 

Hi All,

 

I havea a shape file which I imported it to a table called ‘test2’ (using  SRID=4326).  I want to get centroids of geometries in lat/lon.

 

Here is what I run:

 

select   ST_AsText( ST_Transform(centroid(the_geom),4326)) from ult.test2 limit 5;

 

and what I get:

 

POINT(496597.996430787 2774798.21242881)

POINT(496332.629887436 2793339.61534586)

POINT(496302.627327975 2793317.82477318)

POINT(496305.255261594 2793353.29646291)

POINT(496241.538851096 2774826.65593589)

 

 

So far all is fine except coordinates which are not  latitude/longitude

 

My question is : How can I convert/get these coordinates in lat/lon?

 

 

This what I have in my prj file:

 

PROJCS["Dubai Local Transverse Mercator (DLTM)",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",55.33333333333334],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]

 

 

And this is my postgis version: POSTGIS="1.3.6" GEOS="2.2.3-CAPI-1.1.1" PROJ="Rel. 4.7.1, 23 September 2009" USE_STATS

 

I appreciate any help. Thank you.

 

 

-------------------------------------------------------------------

Mehmet ERKEK

www.REIDIN.com

 


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Please Consider the Environment Before Printing This Email


_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

 


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Please Consider the Environment Before Printing This Email
_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Gmane