[postgis-users] HELP adding spatial field to table

Richard Heimann [C] heimann at ait.nrl.navy.mil
Tue Dec 11 16:15:23 PST 2007


I don't care what happens with invalid values. 

I couldn't get the first query to work and second returns with no results
with no idea what you are suggesting. :-0

I did however (now understanding the error) created a table that had valid
numbers and successful perform the pointfromtext concatenation query. 

 


-----Original Message-----
From: Michael Smedberg [mailto:Michael.Smedberg at redfin.com] 
Sent: Tuesday, December 11, 2007 7:01 PM
To: Richard.Heimann at nrl.navy.mil; PostGIS Users Discussion
Subject: RE: [postgis-users] HELP adding spatial field to table

Something simple like:

UPDATE
	crimetest
SET 
	geom = PointFromText('POINT(' || x || ' ' || y || ')', 4326)
WHERE
	x IS NOT NULL AND
	y IS NOT NULL


UPDATE
	crimetest
SET 
	geom = PointFromText('POINT(0 0)', 4326)
WHERE
	x IS NULL OR
	y IS NULL

Would work, but you might want to do something more clever.  I'm not
sure what you'd like in the geom column when x or y is invalid.


-----Original Message-----
From: Richard Heimann [C] [mailto:heimann at ait.nrl.navy.mil] 
Sent: Tuesday, December 11, 2007 3:58 PM
To: Michael Smedberg; Richard.Heimann at nrl.navy.mil; 'PostGIS Users
Discussion'
Subject: RE: [postgis-users] HELP adding spatial field to table

Thanks for the prompt response. And youre right there are some such
values.
Is there a work around?

 Rich


-----Original Message-----
From: Michael Smedberg [mailto:Michael.Smedberg at redfin.com] 
Sent: Tuesday, December 11, 2007 6:55 PM
To: Richard.Heimann at nrl.navy.mil; PostGIS Users Discussion
Subject: RE: [postgis-users] HELP adding spatial field to table

Are you sure that x and y always have legit values?  If one were null or
the zero-length string, I think you'd get an error like that.

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Richard Heimann [C]
Sent: Tuesday, December 11, 2007 3:44 PM
To: 'PostGIS Users Discussion'
Subject: [postgis-users] HELP adding spatial field to table

 All,

Im getting some strange behavior that I cant explain and sadly know its
likely trivial. My pursuit is simple, add a spatial filed to a table
containing x,y. 

First. AddGeometryColumn

 	SELECT AddGeometryColumn( 'crimetest', 'geom', 4326, 'POINT', 2)

Next (and where the trouble lies) 

	UPDATE crimetest
	SET geom = PointFromText('POINT(' || x || ' ' || y || ')', 4326)

This is the error I receive.

ERROR: Invalid OGC WKT (too short)
SQL state: XX000
Context: SQL function "geomfromtext" statement 1
SQL function "pointfromtext" statement 1

Can anyone shed some light on this?


Thanks
Rich



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













More information about the postgis-users mailing list