I have a table with all US states geometrical data:
USstate ------- state | The_geom (here filling in random value) AL | 00012312 NM | 000234234 NJ | 0000234534 NY | 00005465 VA | 0000023434456
I want to compute number of neighboring states for each state. I know st_touches() has to be used but I am not able to form the exact query. I think it should be something similar to below:
select count(*) as neighbors, st_touches(s.the_geom, r.the_geom) from USstates as s, USstates as r GROUP BY USsates.state;
I am not sure if this is right. Please let me know how to correct this.