Re: [postgis-users] Shifting linestrings left

2010-12-23 Thread Ben Madin
G'day Sean,

On 24/12/2010, at 2:07 AM, Sean wrote:

> Is this just a visualization issue?  You could store copies of the the
> road line with attribute data indicating direction or have a separate
> table with foreign keys to the geography and the direction data.
> 
> Then, you just symbolize differently based on the attributes.  Offset
> the symbology not the geometry.  This is more correct, it preserves
> the information about the actual road on which they travel.  Showing
> direction of travel is strictly a symbology issue.

It's a mix of both - initially, it was a geometry issue - I have linestrings 
for roads, and for some I have information that suggests that they are dual 
carriageway, and I was wondering if we could approximate the dual carriageway 
by shifting the original geometry a little bit to the left going each way.

Then I realised I had better things to do, so I moved on, but now I have a need 
to show routes going both ways, but using pgRouting they (unsurprisingly) 
following the same lines, and I wanted to show it. Using QGIS I offset the 
symbology, but it doesn't actually seem to works how I wanted (which is nicely 
described by Simon's post), but rather looks like :

<>

cheers (and Happy Christmas etc)

Ben___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Shifting linestrings left

2010-12-23 Thread Ben Madin
G'day Puneet,

On 24/12/2010, at 2:17 AM, Puneet Kishor wrote:

> Sean wrote:
>> Is there a way to 'shift' the linestring to the left - after all,
> > that would be sensible side of the road to drive on...
> 
> Which world do you live in? After all, the right side of the road is called 
> the "right side" for a reason.

I thought my accent would have given that away by now!

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Point in Poly just not working

2010-12-23 Thread Paul Ramsey
Jason,

You're inappropriately mixing coordinate reference systems.

As an aside, you don't need to add a spatial_ref_sys entry, if you've
loaded the default PostGIS spatial_ref_sys table, the entry for 29610
is NAD823/UTM10N.

The key problem in your query is this part:

ST_GeomFromText('POINT(-123.097172 49.284562)', 1)

Having defined SRID 1 as UTM10N, you then say, "here's a point, treat
the coordinates as if they are UTM10N". But those coordinates are not
UTM10N, they are geographic coordinates from Google Maps,
longitude/latitude on a WGS83 spheroid... SRID 4326 in the standard
PostGIS spatial ref sys table.

Ah! So, can you just replace '1' with '4326' in your
ST_GeomFromText()? Not quite. Because then you'll be doing an
ST_Contains() test with a different SRID for each argument, and that's
not legal! So you need to transform one side into a matching SRID. The
final, working query, will look like this:

select ST_Contains(c.the_geom,
ST_Transform(ST_GeomFromText('POINT(-123.097172 49.284562)', 4326),1))
from city_boundary c;

Happy holidays,
Paul

On Thu, Dec 23, 2010 at 11:09 AM, Jason Leach  wrote:
> Hi:
> I'm just not having any luck determining if a point is in a polygon.
> 1. I add my SRID for NAD_1983_UTM_Zone_10N to the spatial ref.
> 2. Importing the City of Vancouver's boundary (MULTILINESTRING) with -s 1
> (SRID=1) and load the SQL file.
> 3. Pick a point within the city from google map: 49.284562,-123.097172
> 4. Check if the point is in the boundary:
> covciv=# select ST_Contains(c.the_geom, ST_GeomFromText('POINT(49.284562
> -123.097172)', 1)) from city_boundary c;
>  st_contains
> -
>  f
> (1 row)
> covciv=# select ST_Contains(c.the_geom, ST_GeomFromText('POINT(-123.097172
> 49.284562)', 1)) from city_boundary c;
>  st_contains
> -
>  f
> (1 row)
> I've also tried this with MULTIPOLYGON data in case MULTILINESTRING was the
> problem.
>
> Any tips would be appreciated.
>
> The shape file's proj:
> PROJCS["NAD_1983_UTM_Zone_10N",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",50],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",-123],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0],UNIT["Meter",1]]
> My proj with SRID = 1;
> INSERT INTO  spatial_ref_sys VALUES
> (1,NULL,NULL,'PROJCS[''NAD_1983_UTM_Zone_10N'',
> GEOGCS[''GCS_North_American_1983'', DATUM[''D_North_American_1983'',
> SPHEROID[''GRS_1980'',6378137,298.257222101]], PRIMEM[''Greenwich'',0],
> UNIT[''Degree'',0.0174532925199433]], PROJECTION[''Transverse_Mercator''],
> PARAMETER[''False_Easting'',50.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]]');
> ___
> postgis-users mailing list
> postgis-users@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


[postgis-users] Point in Poly just not working

2010-12-23 Thread Jason Leach
Hi:

I'm just not having any luck determining if a point is in a polygon.

1. I add my SRID for NAD_1983_UTM_Zone_10N to the spatial ref.
2. Importing the City of Vancouver's boundary (MULTILINESTRING) with -s 1 
(SRID=1) and load the SQL file.
3. Pick a point within the city from google map: 49.284562,-123.097172
4. Check if the point is in the boundary:

covciv=# select ST_Contains(c.the_geom, ST_GeomFromText('POINT(49.284562 
-123.097172)', 1)) from city_boundary c;
 st_contains 
-
 f
(1 row)

covciv=# select ST_Contains(c.the_geom, ST_GeomFromText('POINT(-123.097172 
49.284562)', 1)) from city_boundary c;
 st_contains 
-
 f
(1 row)

I've also tried this with MULTIPOLYGON data in case MULTILINESTRING was the 
problem.
 
Any tips would be appreciated.


The shape file's proj:

PROJCS["NAD_1983_UTM_Zone_10N",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",50],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",-123],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0],UNIT["Meter",1]]

My proj with SRID = 1;

INSERT INTO  spatial_ref_sys VALUES 
(1,NULL,NULL,'PROJCS[''NAD_1983_UTM_Zone_10N'', 
GEOGCS[''GCS_North_American_1983'', DATUM[''D_North_American_1983'', 
SPHEROID[''GRS_1980'',6378137,298.257222101]], PRIMEM[''Greenwich'',0], 
UNIT[''Degree'',0.0174532925199433]], PROJECTION[''Transverse_Mercator''], 
PARAMETER[''False_Easting'',50.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]]');___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


[postgis-users] rtpostgis errors

2010-12-23 Thread paolo
Hi all.
After compiling from svn, I get a few errors while uploading
rtpostgis.sql.
Any hint?
Thanks a lot.
===
$ psql -d test -f raster/rt_pg/rtpostgis.sql
psql:raster/rt_pg/rtpostgis.sql:32: NOTICE:  type "raster" is not yet
defined
DETTAGLI: Creating a shell type definition.
CREATE FUNCTION
psql:raster/rt_pg/rtpostgis.sql:37: NOTICE:  argument type raster is
only a shell
...
psql:raster/rt_pg/rtpostgis.sql:77: ERROR:  function st_box2d(geometry)
does not exist
RIGA 3: AS 'select st_box2d(st_convexhull($1))'
   ^
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.
...
psql:raster/rt_pg/rtpostgis.sql:947: ERROR:  function st_box2d(raster)
does not exist
...
psql:raster/rt_pg/rtpostgis.sql:1352: NOTICE:  CREATE TABLE / PRIMARY
KEY will create implicit index "raster_columns_pk" for table
"raster_columns"
CREATE TABLE
psql:raster/rt_pg/rtpostgis.sql:1375: NOTICE:  CREATE TABLE / PRIMARY
KEY will create implicit index "raster_overviews_pk" for table
"raster_overviews"


___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Shifting linestrings left

2010-12-23 Thread Puneet Kishor



Sean wrote:

Is there a way to 'shift' the linestring to the left - after all,

> that would be sensible side of the road to drive on...

Which world do you live in? After all, the right side of the road is 
called the "right side" for a reason.


;-)

--
Puneet Kishor
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Shifting linestrings left

2010-12-23 Thread Sean
Is this just a visualization issue?  You could store copies of the the
road line with attribute data indicating direction or have a separate
table with foreign keys to the geography and the direction data.

Then, you just symbolize differently based on the attributes.  Offset
the symbology not the geometry.  This is more correct, it preserves
the information about the actual road on which they travel.  Showing
direction of travel is strictly a symbology issue.

Sean



On Dec 22, 9:13 pm, Ben Madin  wrote:
> G'day all,
>
> I have a problem where I am trying to show the route of livestock movements, 
> but I am loosing information when the travel along the same road in different 
> directions (ie in some cases they travel from a saleyard to a feedlot, then 
> back to the saleyard after a period). The roads they travel along are single 
> linestrings.
>
> Is there a way to 'shift' the linestring to the left - after all, that would 
> be sensible side of the road to drive on...
>
> cheers
>
> Ben
>
> ___
> postgis-users mailing list
> postgis-us...@postgis.refractions.nethttp://postgis.refractions.net/mailman/listinfo/postgis-users
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Shifting linestrings left

2010-12-23 Thread Charles Galpin
Just FYI, I have tries upgis_lineshift and in general it does a great job - at 
a minimum for visualizing the different paths. However I have found that 
sometimes the shifted line doesn't go in the direction you'd expect so you'll 
get situations where the shifting switches sides and this can be problematic if 
you are expecting them to represent the actual side of the road of that lane.

In the diagram below the …… line is the original geometry for a singly 
digitized road, and the - - -  is the shifted line. 

- - - - - - - - - -
………...
  - - - - - - - - - - - 

I have not had time to look into this, but hope to at some point.

hth
charles

On Dec 23, 2010, at 1:03 AM, Simon Greener wrote:

> Ben,
> See Regina Obe's upgis_lineshift
> http://trac.osgeo.org/postgis/wiki/UsersWikiplpgsqlfunctions
> I have a PostGIS version, without the curves, of this one:
> http://www.spatialdbadvisor.com/oracle_spatial_tips_tricks/97/implementing-a-move-parallel-function-for-sdo_geometry-linestring-data-in-oracle
> If you want the code, email me privately as I have not yet blogged on it.
> Simon
> On Thu, 23 Dec 2010 14:56:49 +1100, Ben Madin 
>  wrote:
> 
>> Thanks Brent,
>> 
>> Happy Christmas / New Year to you as well!
>> 
>> On 23/12/2010, at 2:07 PM, pcr...@pcreso.com wrote:
>> 
>>> ST_Translate() is the simplest, but if your lines are horizontal you may 
>>> want a Y shift as well?
>>> 
>>> http://postgis.refractions.net/documentation/manual-svn/ST_Translate.html
>> 
>> Lines are roads, so they go every which way.
>> 
>>> Having done this, I suggest you also use ST_reverse() to reflect the 
>>> direction is now going the other way (unless it already is :-)
>>> http://postgis.refractions.net/documentation/manual-svn/ST_Reverse.html
>>> 
>>> For more complex shifting of features, probably overkill in your case, see
>>> http://postgis.refractions.net/documentation/manual-svn/ST_Affine.html
>> 
>> This might be what I am after, but I was thinking of somehow translating 
>> each segment parallel to it's current alignment and then rejoining with a 
>> nice smooth curve... kind of like a 1-sided buffer.
>> 
>> cheers
>> 
>> Ben
>> 
>> 
>> 
>> 
>> 
>>> --- On Thu, 12/23/10, Ben Madin  wrote:
>>> 
>>> From: Ben Madin 
>>> Subject: [postgis-users] Shifting linestrings left
>>> To: "PostGIS Users Discussion" 
>>> Date: Thursday, December 23, 2010, 3:13 PM
>>> 
>>> G'day all,
>>> 
>>> I have a problem where I am trying to show the route of livestock 
>>> movements, but I am loosing information when the travel along the same road 
>>> in different directions (ie in some cases they travel from a saleyard to a 
>>> feedlot, then back to the saleyard after a period). The roads they travel 
>>> along are single linestrings.
>>> 
>>> Is there a way to 'shift' the linestring to the left - after all, that 
>>> would be sensible side of the road to drive on...
>>> 
>>> cheers
>>> 
>>> Ben
>>> 
>>> 
>>> ___
>>> postgis-users mailing list
>>> postgis-users@postgis.refractions.net
>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>> 
>> ___
>> postgis-users mailing list
>> postgis-users@postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>> 
> 
> 
> -- 
> SpatialDB Advice and Design, Solutions Architecture and Programming,
> Oracle Database 10g Administrator Certified Associate; Oracle Database 10g 
> SQL Certified Professional
> Oracle Spatial, SQL Server, PostGIS, MySQL, ArcSDE, Manifold GIS, FME, Radius 
> Topology and Studio Specialist.
> 39 Cliff View Drive, Allens Rivulet, 7150, Tasmania, Australia.
> Website: www.spatialdbadvisor.com
>  Email: si...@spatialdbadvisor.com
>  Voice: +61 362 396397
> Mobile: +61 418 396391
> Skype: sggreener
> Longitude: 147.20515 (147° 12' 18" E)
> Latitude: -43.01530 (43° 00' 55" S)
> GeoHash: r22em9r98wg
> NAC:W80CK 7SWP3
> ___
> postgis-users mailing list
> postgis-users@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] what to do about TopologyExceptions

2010-12-23 Thread David Kaplan
Hi,

I thought I had everything figured out with respect to my problems
unioning and differencing polygons, but I am running into more
TopologyExceptions that have me confused.  

After looking at Paul Ramsey's FOSS4G presentation, I realized that what
I really wanted to do was an "ArcGIS Union Operation" - i.e. reducing a
set of overlapping polygons into all possible combinations of overlaps.
My table consists of a set of MULTIPOLYGONs that sometimes overlap.  I
used ST_Buffer(0) to force them to be valid polygons (and checked this
worked correctly).  Then I did the following to reduce every polygon to
just the LINESTRINGs that define them:

SELECT ST_ExteriorRing((ST_DumpRings((ST_Dump(wkb_geometry)).geom)).geom) AS 
geom
INTO TEMP TABLE ht1 FROM my_geo_table;

Note that I added ST_ExteriorRing to ST_DumpRings to reduce polygons to
linestrings.  Is this correct?

Then I wanted to union these linestrings to assure that they have all
the nodes at overlaps, but I keep getting a TopologyException:

SELECT ST_Union(geom) AS geom INTO TEMP TABLE ht2 FROM ht1;
NOTICE:  TopologyException: found non-noded intersection between LINESTRING 
(-165.443 23.1836, -165.443 23.1836) and LINESTRING (-165.443 23.1836, -165.464 
23.2079) at -165.443 23.1836
ERROR:  GEOS union() threw an error!

Presuming the coordinates given are actual geographic coordinates, it
appears that this problem occurs at a location that two different
linestrings just barely overlap (see attached image).  Is this a
postgis / GEOS problem or is there something that I am doing that is
conceptually wrong?  In either case, is there a way to move forward?

The next steps in the process would be to use ST_Polygonize to get back
a bunch of polygons, ST_PointOnSurface to find interior points and
ST_Intersects to find the original polygons these points belonged to.

Thanks again for the help.

Cheers,
David


On Mon, 2010-12-20 at 17:49 +0100, Peter Hopfgartner wrote:
> AFAIK there are slightly different definitions of valid polygon between shape 
> files and PostGIS/Simple Features.
> Paul Ramsey had a talk on a number of tricks to correct those problems (and 
> some more):
> http://2010.foss4g.org/presentations_show.php?id=3369.
> 
> Peter Hopfgartner
>  
> R3 GIS Srl - GmbH
> http://www.r3-gis.com
> 
> 
> David Kaplan  wrote
> Subject: [postgis-users] what to do about TopologyExceptions
> Date: 20.12.2010 09:54
> 
> >Hi,
> >
> >I am working with a GIS table that is derived from importing a fairly
> >complex shapefile.  I want to do a number of union and difference
> >operations, but I am encountering TopologyException problems and am
> >wondering how much attention I need to pay to these exceptions and what
> >is the best way to deal with these problems.
> >
> >For example, upon doing a simple union operation, I have:
> >
> >CREATE TABLE by_country_iucn AS
> >SELECT min(ogc_fid) AS ogc_fid, country, iucn_cat, 
> >   ST_Multi( ST_Union( wkb_geometry ) ) AS wkb_geometry
> >FROM pol_2010
> >GROUP BY country, iucn_cat
> >ORDER BY country, iucn_cat;
> >
> >I get the following exception at the end:
> >
> >NOTICE:  TopologyException: side location conflict at 29.1972 0.251105
> >
> >However, I am not sure what to do with this for two reasons:
> >
> >1) The point indicated in the exception (presuming this is a 2D point
> >location) is located in the middle of nowhere and none of my polygons
> >come anywhere near it (the nearest is >1000 km away).
> >
> >2) Looking at the result of the union, I don't see any obvious problems.
> >Do these exceptions mean I am missing some part of the desired union?
> >
> >For the union, this returns a result no problem, but for the difference
> >operations that follow it, the query fails with no result after a
> >similar exception.
> >
> >I saw in a previous thread that I should use ST_IsValid to test for
> >problems.  I applied this to my shapefile and it found lots of results.
> >Looking at the "bad" polygons, many look fine to the naked eye, but some
> >do have strange things like internal lines.  Is there a good way to fix
> >these?  ST_SimplifyPreserveTopology?  Will doing this help the other
> >union and difference manipulations?
> >
> >Thanks for the help.
> >
> >Cheers,
> >David
> >
> >-- 
> >**
> >David M. Kaplan
> >Charge de Recherche 1
> >
> >Institut de Recherche pour le Developpement
> >Centre de Recherche Halieutique Mediterraneenne et Tropicale
> >av. Jean Monnet
> >B.P. 171
> >34203 Sete cedex
> >France
> >
> >Phone: +33 (0)4 99 57 32 27
> >Fax: +33 (0)4 99 57 32 95
> >
> >http://www.ur097.ird.fr/team/dkaplan/index.html
> >http://www.amped.ird.fr/
> >**
> >
> >
> >___
> >postgis-users mailing list
> >postgis-users@postgis.refractions.net
> >http://postgis.refractions.net/mailman/listinfo/postgis-users
> >
> 

-- 
**
David M. Kaplan
Charge de Recherche 1

Ins