From urban segregation to spatial structure detection