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.

Following the pgRouting workshop here, I have the routing query below:

$sql = "SELECT gid, start_id AS source, end_id AS target, the_geom, 
                  distance(the_geom, GeometryFromText(
                       'POINT(".$lonlat[0]." ".$lonlat[1].")', 4326)) AS dist 
                 FROM ".TABLE."  
                 WHERE the_geom && setsrid(
                       'BOX3D(".($lonlat[0]-0.1)." 
                              ".($lonlat[1]-0.1).", 
                              ".($lonlat[0]+0.1)." 
                              ".($lonlat[1]+0.1).")'::box3d, 4326) 
                 ORDER BY dist LIMIT 1";

This query fails with the error: Query failed: ERROR: Operation on two geometries with different SRIDs. Now, I've been looking around and came across this. I've tried the suggestions on this post, but the error persists. Any idea on how to fix this will be appreciated.

UPDATE: Running SELECT st_srid(the_geom) FROM table_name against my database table returns -1. In my query and map, the assumed external projection is EPSG:4326. Is changing this value likely to help? Is there any harm in changing the srid value directly in the database? How can I go about changing the srid value in the database if it doesn't present any risk?

UPDATE: I had to change the srid of the column from the UNKNOWN indicator of -1 to 4326. The answer at this StackOverflow post was very helpful in this. Also, the question in this SE GIS post was instrumental in helping me in the right direction.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

I had to change the srid of the column from the UNKNOWN indicator of -1 to 4326. The answer at this StackOverflow post was very helpful in this. Also, the question in this SE GIS post was instrumental in helping me in the right direction.

Summarily: Running UPDATE table_name SET the_geom = ST_SetSRID(the_geom, 4326) and UPDATE table_name SET the_geom = ST_Tranform(the_geom, 4326) did it.

share|improve this answer
    
you should be able to accept your own answer so the thread can be marked as closed –  underdark Oct 3 '12 at 16:26
    
For some reason I had to do a VACUUM ANALYZE table_name after this to really get rid of the error. –  kontextify Dec 22 at 5:41

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.