Deal of the Day

Home » Main » Manning Forums » 2009 » PostGIS in Action

Thread: Errors and Corrections

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 26 - Pages: 2 [ 1 2 | Next ] - Last Post: Feb 25, 2013 6:01 AM by: griffilo Threads: [ Previous | Next ]
luke.bace

Posts: 66
Registered: 7/7/09
Errors and Corrections
Posted: Jan 4, 2011 10:09 PM
  Click to reply to this thread Reply

Please post all errata here.

Greener

Posts: 6
From: New Jersey
Registered: 11/20/10
Re: Errors and Corrections
Posted: Jan 19, 2011 7:18 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

In chapter 1, after importing the shapfile.

I added geom attribute based on the script below:
SELECT AddGeometryColumn('ch01', 'roads', 'geom', 2163, 'MULTILINESTRING',2);

Then....
The following script generates an error.
UPDATE ch01.roads
SET geom =
ST_Transform(geom_4269, 2163);
//-------------------------------------------------------------------
ERROR: Input geometry has unknown (-1) SRID
SQL state: XX000
//------------------------------------------------------------------
I am not sure why it is doing it.
SRID -> 2163 is valid
Any help would appreciate it.
Chris

regina.leo

Posts: 230
Registered: 5/6/09
Re: Errors and Corrections
Posted: Jan 19, 2011 8:33 PM   in response to: Greener in response to: Greener
  Click to reply to this thread Reply

Check to make sure your geom_4269 has an SRID other than 0 or -1.

SELECT ST_SRID(geom_4269) from ch01.roads;

If it doesn't have a alid srid, then I think ST_Transform gives that error because it wouldn't know the formula to use to transform from unknown to 2163.

What command did you use to import the table or did you use the gui loader? Its possible you missed the -s 4269 switch or there is a bug in the loader version you have.

If that is the case, the easy remedy is to do this instead:

UPDATE ch01.roads
SET geom =
ST_Transform(ST_SetSRID(geom_4269,4269), 2163);

regina.leo

Posts: 230
Registered: 5/6/09
Re: Errors and Corrections
Posted: Jan 19, 2011 8:35 PM   in response to: regina.leo in response to: regina.leo
  Click to reply to this thread Reply

slight correction:

SELECT DISTINCT ST_SRID(geom_4269) from ch01.roads;

Greener

Posts: 6
From: New Jersey
Registered: 11/20/10
Re: Errors and Corrections
Posted: Jan 21, 2011 4:40 PM   in response to: regina.leo in response to: regina.leo
  Click to reply to this thread Reply

Hello Regina,
I used to GUI PostGIS shapeloader tool.
You are correct that I had value -1.
I used your update sql and it worked.
I was able to perform the rest of other queries in the chapter 1.
Onto the chapter 2...
Excellent book; and very happy that you are present on the forum.

Thank you for your assistance.
Chris

Gyula_58

Posts: 13
Registered: 12/30/10
Re: Errors and Corrections
Posted: Jan 26, 2011 4:02 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

After the code in listing 5.12:

There are three import things about using DISTINCT ON.

maybe important?

regina.leo

Posts: 230
Registered: 5/6/09
Re: Errors and Corrections
Posted: Jan 26, 2011 5:14 AM   in response to: Gyula_58 in response to: Gyula_58
  Click to reply to this thread Reply

Thanks. -- that one slipped by too :(

Gyula_58

Posts: 13
Registered: 12/30/10
Re: Errors and Corrections
Posted: Jan 31, 2011 1:56 AM   in response to: regina.leo in response to: regina.leo
  Click to reply to this thread Reply

Example in App.C.

SELECT c.city_name
FROM city As c
LEFT JOIN airports As a ON a.city_code=c.city_code
WHERE a.airport_code IS NULL;

text in bold is missing from the code

Gyula_58

Posts: 13
Registered: 12/30/10
Re: Errors and Corrections
Posted: Jan 31, 2011 2:10 AM   in response to: Gyula_58 in response to: Gyula_58
  Click to reply to this thread Reply

Chapter 7.

ogr2ogr -f "MapInfo file" /gisdata/biketrip.tab PG:"host=localhost user=postgres port=5432 dbname=postgis_in_action password=mypassword" –select "SELECT track_seg_point_id, ele, time" -where "time BETWEEN '2009-07-18 04:33-04' AND '2009-07-18 04:34-04'" staging.aus_biketrip_narangba

SELECT in bold is needless and the same applies to the similar KML example as well.
After correcting the select surplus, the script was not still operating, I suppose because of the format of timestamps, but I did not have more time to play with it.

Gyula_58

Posts: 13
Registered: 12/30/10
Re: Errors and Corrections
Posted: Jan 31, 2011 2:58 AM   in response to: Gyula_58 in response to: Gyula_58
  Click to reply to this thread Reply

Appendix C

SELECT p.product_name, s.state, p.base_price * (1 + s.tax) As total_price
FROM products AS p
CROSS JOIN state AS s;
-- 1 Can also be written as

SELECT p.product_name, s.state,p.base_price * (1 + s.tax) As total_price
FROM products AS p, state AS s

...added the part in bold still is necessary...

Gyula_58

Posts: 13
Registered: 12/30/10
Re: Errors and Corrections
Posted: Jan 31, 2011 4:31 AM   in response to: Gyula_58 in response to: Gyula_58
  Click to reply to this thread Reply

Appendix C.

SELECT c.last_name, c.first_name, r.rental_id, p.amount, p.payment_date
FROM customer As C
INNER JOIN rental As r ON C.customer_id = r.customer_id
LEFT JOIN payment As p
ON (p.customer_id = r.customer_id AND p.rental_id r.customer_id);

Well, AND requires boolean data types on both sides.
I guess, neither p.rental_id nor r.customer_id are boolean values, so something must be missing here...

regina.leo

Posts: 230
Registered: 5/6/09
Re: Errors and Corrections
Posted: Jan 31, 2011 5:33 AM   in response to: Gyula_58 in response to: Gyula_58
  Click to reply to this thread Reply

Good catch. Thanks.

regina.leo

Posts: 230
Registered: 5/6/09
Re: Errors and Corrections
Posted: Jan 31, 2011 6:12 AM   in response to: Gyula_58 in response to: Gyula_58
  Click to reply to this thread Reply

We seem to have made the same mistake with the KML one.

Regarding the other issue you are having why its still not working. I'm afraid its the evils of MS Word at work. Somewhere along the line, I think it replaced our - with a smart dash and the " possibly with smart quotes.

Gyula_58

Posts: 13
Registered: 12/30/10
Re: Errors and Corrections
Posted: Jan 31, 2011 7:47 AM   in response to: Gyula_58 in response to: Gyula_58
  Click to reply to this thread Reply

Appendix C.

SELECT n.nei_name,
SUM(ST_Length(road.the_geom)) as total_road_length,
ST_Extent(road.the_geom) As total_extent,
COUNT(DISTINCT road.road_name) As count_of_roads
FROM neighborhoods As n
INNER JOIN roads ON
ST_Intersects(neighborhoods.the_geom, roads.the_geom)
WHERE n.city = 'Boston'
GROUP BY n.nei_name
HAVING ST_Area(ST_Extent(road.the_geom)) > 1000;

the table names underlined in the code should be roads...

albickers

Posts: 2
Registered: 3/5/11
Re: Errors and Corrections
Posted: Mar 5, 2011 6:32 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

3.3 (Using rules and triggers). Minor but...

The two mechanism for handling the conditional

Should be mechanisms

Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Manning Developmental Editor