Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am using the following postgis query for updating a pgrouting table from my custom road data. In the x(ST_StartPoint(part_geom)) as x1, line its returning an error mentioned

ERROR: function x(geometry) does not exist

INSERT INTO public.roads_r (
SELECT DISTINCT ON (the_geom)
nextval('public.roads_r_gid_seq') AS gid,
gid AS parent_gid,
name,
no,
type,
NULL as source,
NULL as target,
ST_Length(part_geom, true) as cost,
ST_Length(part_geom, true) as reverse_cost,
x(ST_StartPoint(part_geom)) as x1,
y(ST_StartPoint(part_geom)) as y1,
x(ST_EndPoint(part_geom)) as x2,
y(ST_EndPoint(part_geom)) as y2,
NULL as to_cost,
NULL as rule,
ST_Multi(part_geom) AS the_geom
FROM (
    SELECT 
        a.gid, 
        a.geom, 
        (ST_Dump(ST_Union(b.geom))).geom AS part_geom, 
        a.road_name as name,
        a.road_no as no,
        a.road_type as type
    FROM public.roads as a, public.roads as b
    WHERE ST_Intersects(a.geom, b.geom)
    GROUP BY a.gid, a.geom, a.road_name, a.road_no, a.road_type
) AS res
WHERE ST_Contains(geom, part_geom) = true OR ST_Contains(ST_Buffer(geom, 0.00001), part_geom) = true)

Any help will be highly appreciated.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

No function exists in PostGIS called "x", as the error is telling you.

I am guessing you want to be using the ST_X() and ST_Y() functions, instead.

share|improve this answer
    
I got another problem in the same code. Now its indication "ST_Multi(part_geom) AS the_geom" and returning an error "INSERT has more expressions than target columns". Could you please give me a kind suggestion? –  Devils Dream Jun 24 '13 at 22:05
add comment

I think ST_X(geom) is what you are looking for.

where did you find that x(geom) syntax?

share|improve this answer
    
I got another problem in the same code. Now its indication "ST_Multi(part_geom) AS the_geom" and returning an error "INSERT has more expressions than target columns". Could you please give me a kind suggestion? –  Devils Dream Jun 24 '13 at 22:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.